From f1022bcc12dbdf5b7974fb1510197b12214fec32 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 9 Oct 2008 19:17:44 +0200 Subject: update: job ID must be positive The documentation for directory_update_init() was incorrect: a job ID must be positive, not non-negative. If the update queue is full and no job was created, it makes more sense to return 0 instead of -1, because it is more consistent with the return value of isUpdatingDB(). --- src/command.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'src/command.c') diff --git a/src/command.c b/src/command.c index c98bc20e7..1d2645cd1 100644 --- a/src/command.c +++ b/src/command.c @@ -803,31 +803,27 @@ static int handlePlaylistMove(struct client *client, return print_playlist_result(client, result); } -static int print_update_result(struct client *client, int ret) -{ - if (ret >= 0) { - client_printf(client, "updating_db: %i\n", ret); - return 0; - } - if (ret == -2) - command_error(client, ACK_ERROR_ARG, "invalid path"); - else - command_error(client, ACK_ERROR_UPDATE_ALREADY, - "already updating"); - return -1; -} - static int handleUpdate(struct client *client, mpd_unused int argc, char *argv[]) { char *path = NULL; + int ret; assert(argc <= 2); if (argc == 2 && !(path = sanitizePathDup(argv[1]))) { command_error(client, ACK_ERROR_ARG, "invalid path"); return -1; } - return print_update_result(client, directory_update_init(path)); + + ret = directory_update_init(path); + if (ret > 0) { + client_printf(client, "updating_db: %i\n", ret); + return 0; + } else { + command_error(client, ACK_ERROR_UPDATE_ALREADY, + "already updating"); + return -1; + } } static int handleNext(mpd_unused struct client *client, -- cgit v1.2.3