Add the terminator "/" to directory names when returning directory listings from the web interface
This commit is contained in:
+9
-5
@@ -61,18 +61,22 @@ bool process_completion_read_dir(ProxyState *state,
|
|||||||
if (completion.type == TOASTY_RESULT_LIST_SUCCESS) {
|
if (completion.type == TOASTY_RESULT_LIST_SUCCESS) {
|
||||||
http_response_builder_status(operation->builder, 200);
|
http_response_builder_status(operation->builder, 200);
|
||||||
for (int i = 0; i < completion.listing.count; i++) {
|
for (int i = 0; i < completion.listing.count; i++) {
|
||||||
|
|
||||||
|
ToastyListingEntry *entry = &completion.listing.items[i];
|
||||||
|
|
||||||
char vtag[32];
|
char vtag[32];
|
||||||
int ret = snprintf(vtag, sizeof(vtag), "%lu", completion.listing.items[i].vtag);
|
int ret = snprintf(vtag, sizeof(vtag), "%lu", entry->vtag);
|
||||||
if (ret < 0 || ret >= (int) sizeof(vtag)) {
|
if (ret < 0 || ret >= (int) sizeof(vtag)) {
|
||||||
http_response_builder_status(operation->builder, 500); // Internal Server Error
|
http_response_builder_status(operation->builder, 500); // Internal Server Error
|
||||||
http_response_builder_send(operation->builder);
|
http_response_builder_send(operation->builder);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
http_response_builder_body(operation->builder, (HTTP_String) {
|
http_response_builder_body(operation->builder, (HTTP_String) { entry->name, strlen(entry->name) });
|
||||||
completion.listing.items[i].name,
|
if (entry->is_dir) {
|
||||||
strlen(completion.listing.items[i].name),
|
http_response_builder_body(operation->builder, HTTP_STR("/ "));
|
||||||
});
|
} else {
|
||||||
http_response_builder_body(operation->builder, HTTP_STR(" "));
|
http_response_builder_body(operation->builder, HTTP_STR(" "));
|
||||||
|
}
|
||||||
http_response_builder_body(operation->builder, (HTTP_String) { vtag, ret });
|
http_response_builder_body(operation->builder, (HTTP_String) { vtag, ret });
|
||||||
http_response_builder_body(operation->builder, HTTP_STR("\n"));
|
http_response_builder_body(operation->builder, HTTP_STR("\n"));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user