aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/command.c26
-rw-r--r--src/database.c2
-rw-r--r--src/update.c4
-rw-r--r--src/update.h4
4 files changed, 16 insertions, 20 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,
diff --git a/src/database.c b/src/database.c
index bd069f8b4..2581e408b 100644
--- a/src/database.c
+++ b/src/database.c
@@ -46,7 +46,7 @@ db_init(void)
music_root = directory_new("", NULL);
ret = directory_update_init(NULL);
- if (ret < 0)
+ if (ret == 0)
FATAL("directory update failed\n");
do {
diff --git a/src/update.c b/src/update.c
index 9cb3739be..a962cca98 100644
--- a/src/update.c
+++ b/src/update.c
@@ -436,9 +436,9 @@ int directory_update_init(char *path)
int next_task_id;
if (!path)
- return -1;
+ return 0;
if (update_paths_nr == ARRAY_SIZE(update_paths))
- return -1;
+ return 0;
assert(update_paths_nr < ARRAY_SIZE(update_paths));
update_paths[update_paths_nr++] = path;
next_task_id = update_task_id + update_paths_nr;
diff --git a/src/update.h b/src/update.h
index 0c0d74416..5c7277e32 100644
--- a/src/update.h
+++ b/src/update.h
@@ -23,8 +23,8 @@
int isUpdatingDB(void);
/*
- * returns the non-negative update job ID on success,
- * returns -1 if busy
+ * returns the positive update job ID on success,
+ * returns 0 if busy
* @path will be freed by this function and should not be reused
*/
int directory_update_init(char *path);