Merge pull request #1134 from chme/podcast-updates

[library] Directly notify listeners of db changes after adding new items
This commit is contained in:
Christian Meffert 2021-01-09 11:21:42 +01:00 committed by GitHub
commit 724cfa0093
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 3 deletions

View File

@ -3581,7 +3581,7 @@ jsonapi_reply_library_playlist_delete(struct httpd_request *hreq)
return HTTP_BADREQUEST;
}
db_pl_delete(pl_id);
library_playlist_remove_byid(pl_id);
return HTTP_NOCONTENT;
}

View File

@ -553,6 +553,16 @@ item_add(void *arg, int *retval)
}
}
scanning = false;
if (ret == LIBRARY_OK)
{
if (handle_deferred_update_notifications())
listener_notify(LISTENER_UPDATE | LISTENER_DATABASE);
else
listener_notify(LISTENER_UPDATE);
}
*retval = ret;
return COMMAND_END;
}
@ -732,6 +742,25 @@ library_playlist_remove(char *virtual_path)
return commands_exec_sync(cmdbase, playlist_remove, NULL, virtual_path);
}
int
library_playlist_remove_byid(int pl_id)
{
if (scanning)
{
DPRINTF(E_INFO, L_LIB, "Scan already running, ignoring request to remove playlist '%d'\n", pl_id);
return -1;
}
db_pl_delete(pl_id);
if (handle_deferred_update_notifications())
listener_notify(LISTENER_UPDATE | LISTENER_DATABASE);
else
listener_notify(LISTENER_UPDATE);
return 0;
}
int
library_queue_save(char *path)
{
@ -762,8 +791,13 @@ library_queue_item_add(const char *path, int position, char reshuffle, uint32_t
int
library_item_add(const char *path)
{
if (library_is_scanning())
return -1;
if (scanning)
{
DPRINTF(E_INFO, L_LIB, "Scan already running, ignoring request to add item '%s'\n", path);
return -1;
}
scanning = true; // TODO Guard "scanning" with a mutex
return commands_exec_sync(cmdbase, item_add, NULL, (char *)path);
}

View File

@ -189,6 +189,9 @@ library_playlist_item_add(const char *vp_playlist, const char *vp_item);
int
library_playlist_remove(char *virtual_path);
int
library_playlist_remove_byid(int plid);
int
library_queue_save(char *path);