aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-09 19:17:44 +0200
committerMax Kellermann <max@duempel.org>2008-10-09 19:17:44 +0200
commitf1022bcc12dbdf5b7974fb1510197b12214fec32 (patch)
treecabe38f9e1f728423b03bab187e6c55157ffad8d /src/command.c
parent79a28e5c72ae01164b88ae6d8a510f47a92d231f (diff)
downloadmpd-f1022bcc12dbdf5b7974fb1510197b12214fec32.tar.gz
mpd-f1022bcc12dbdf5b7974fb1510197b12214fec32.tar.xz
mpd-f1022bcc12dbdf5b7974fb1510197b12214fec32.zip
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().
Diffstat (limited to '')
-rw-r--r--src/command.c26
1 files changed, 11 insertions, 15 deletions
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,