From e099fe118c51f57f84cef4195c3d96b0faa2eae0 Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Tue, 2 Feb 2021 12:01:37 +0100 Subject: [PATCH] MPD: Fix addid command --- src/base/commands.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/base/commands.c b/src/base/commands.c index d942f696..fb9ea207 100644 --- a/src/base/commands.c +++ b/src/base/commands.c @@ -384,13 +384,13 @@ command_add(struct lkt_state *srv, char *args[LKT_MESSAGE_ARGS_MAX], int priorit { RETURN_UNLESS(args && args[0], "Invalid argument", false); struct lkt_uri uri; - int ret; /* To be modified according to the command (insert or add) later (TODO) */ + int ret; RETURN_UNLESS(lkt_uri_from(&uri, args[0]), "Failed to parse query", false); ret = database_queue_add_uri(srv->db, &uri, priority); - srv->mpd_idle_events |= MPD_IDLE_PLAYLIST; lkt_uri_free(&uri); if (!ret) LOG_ERROR("COMMAND", "Failed to add with priority %d in queue", priority); + srv->mpd_idle_events |= MPD_IDLE_PLAYLIST; return ret; } @@ -399,10 +399,9 @@ command_addid(struct lkt_state *srv, char *args[LKT_MESSAGE_ARGS_MAX]) { RETURN_UNLESS(args, "Invalid argument", false); errno = 0; - int i; - struct lkt_uri uri = { .type = uri_id }; - for (i = 0; (uri.id = strtol(args[i], NULL, 0)) && ! errno; ++i) - errno |= database_queue_add_id(srv->db, uri.id, 1); + int i, id; + for (i = 0, id = strtol(args[i], NULL, 0); id != 0 && ! errno; ++i, id = strtol(args[i], NULL, 0)) + errno |= database_queue_add_id(srv->db, id, 1); srv->mpd_idle_events |= MPD_IDLE_PLAYLIST; return ! errno; } -- GitLab