command/playlist: save only if at least one song was added

This commit is contained in:
Max Kellermann
2021-11-11 09:44:47 +01:00
parent b4e72aba6c
commit 651f57bced
3 changed files with 18 additions and 8 deletions

View File

@@ -233,10 +233,12 @@ handle_playlistadd_position(Client &client, const char *playlist_name,
#ifdef ENABLE_DATABASE
const DatabaseSelection selection(uri, true, nullptr);
SearchInsertIntoPlaylist(client.GetDatabaseOrThrow(),
client.GetStorage(),
selection,
editor, position);
if (SearchInsertIntoPlaylist(client.GetDatabaseOrThrow(),
client.GetStorage(),
selection,
editor, position) == 0)
/* no song was found, don't need to save */
return CommandResult::OK;
#else
(void)client;
r.Error(ACK_ERROR_NO_EXIST, "No database");