mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-10 13:18:14 -05:00
[jsonapi] Sort files by filename and return directories in api/config
This commit is contained in:
parent
cd7af46c36
commit
ca99bf8718
@ -632,6 +632,10 @@ jsonapi_reply_config(struct httpd_request *hreq)
|
|||||||
json_object *buildopts;
|
json_object *buildopts;
|
||||||
int websocket_port;
|
int websocket_port;
|
||||||
char **buildoptions;
|
char **buildoptions;
|
||||||
|
cfg_t *lib;
|
||||||
|
int ndirs;
|
||||||
|
char *path;
|
||||||
|
json_object *directories;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
CHECK_NULL(L_WEB, jreply = json_object_new_object());
|
CHECK_NULL(L_WEB, jreply = json_object_new_object());
|
||||||
@ -662,6 +666,17 @@ jsonapi_reply_config(struct httpd_request *hreq)
|
|||||||
}
|
}
|
||||||
json_object_object_add(jreply, "buildoptions", buildopts);
|
json_object_object_add(jreply, "buildoptions", buildopts);
|
||||||
|
|
||||||
|
// Library directories
|
||||||
|
lib = cfg_getsec(cfg, "library");
|
||||||
|
ndirs = cfg_size(lib, "directories");
|
||||||
|
directories = json_object_new_array();
|
||||||
|
for (i = 0; i < ndirs; i++)
|
||||||
|
{
|
||||||
|
path = cfg_getnstr(lib, "directories", i);
|
||||||
|
json_object_array_add(directories, json_object_new_string(path));
|
||||||
|
}
|
||||||
|
json_object_object_add(jreply, "directories", directories);
|
||||||
|
|
||||||
CHECK_ERRNO(L_WEB, evbuffer_add_printf(hreq->reply, "%s", json_object_to_json_string(jreply)));
|
CHECK_ERRNO(L_WEB, evbuffer_add_printf(hreq->reply, "%s", json_object_to_json_string(jreply)));
|
||||||
|
|
||||||
jparse_free(jreply);
|
jparse_free(jreply);
|
||||||
@ -2726,7 +2741,7 @@ jsonapi_reply_library_files(struct httpd_request *hreq)
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
query_params.type = Q_ITEMS;
|
query_params.type = Q_ITEMS;
|
||||||
query_params.sort = S_NAME;
|
query_params.sort = S_VPATH;
|
||||||
query_params.filter = db_mprintf("(f.directory_id = %d)", directory_id);
|
query_params.filter = db_mprintf("(f.directory_id = %d)", directory_id);
|
||||||
|
|
||||||
ret = fetch_tracks(&query_params, tracks_items, &total);
|
ret = fetch_tracks(&query_params, tracks_items, &total);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user