aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-09-28 20:29:40 -0700
committerEric Wong <normalperson@yhbt.net>2008-09-28 20:30:58 -0700
commit887f97b868886a66d7bb2fcd0e1fd6810297299d (patch)
tree7a4f050b0905fb5d0b645dfdb623dcc4fbc36852 /src/command.c
parente7203ca8349f03c5364a97b9dee68a83e4d506dc (diff)
downloadmpd-887f97b868886a66d7bb2fcd0e1fd6810297299d.tar.gz
mpd-887f97b868886a66d7bb2fcd0e1fd6810297299d.tar.xz
mpd-887f97b868886a66d7bb2fcd0e1fd6810297299d.zip
clean up updateInit calling and error handling
Move error reporting to command.c so directory.c does not deal with client error handling any more.
Diffstat (limited to '')
-rw-r--r--src/command.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/command.c b/src/command.c
index 616132bea..ce41abb64 100644
--- a/src/command.c
+++ b/src/command.c
@@ -799,6 +799,16 @@ static int handlePlaylistMove(int fd, mpd_unused int *permission,
return print_playlist_result(fd, result);
}
+static int print_update_result(int fd, int ret)
+{
+ if (ret >= 0) {
+ fdprintf(fd, "updating_db: %i\n", ret);
+ return 0;
+ }
+ commandError(fd, ACK_ERROR_UPDATE_ALREADY, "already updating");
+ return -1;
+}
+
static int listHandleUpdate(int fd,
mpd_unused int *permission,
mpd_unused int argc,
@@ -818,7 +828,7 @@ static int listHandleUpdate(int fd,
nextCmd = getCommandEntryFromString(next->data, permission);
if (cmd != nextCmd)
- return updateInit(fd, pathList);
+ return print_update_result(fd, updateInit(pathList));
return 0;
}
@@ -826,12 +836,14 @@ static int listHandleUpdate(int fd,
static int handleUpdate(int fd, mpd_unused int *permission,
mpd_unused int argc, char *argv[])
{
+ List *pathList = NULL;
+
if (argc == 2) {
- List *pathList = makeList(NULL, 1);
+ pathList = makeList(NULL, 1);
insertInList(pathList, argv[1], NULL);
- return updateInit(fd, pathList);
}
- return updateInit(fd, NULL);
+
+ return print_update_result(fd, updateInit(pathList));
}
static int handleNext(mpd_unused int fd, mpd_unused int *permission,