diff options
author | Max Kellermann <max@duempel.org> | 2008-09-07 13:50:06 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-07 13:50:06 +0200 |
commit | 8e3c40f032d1c760b9dc11df654c577baaf5f76a (patch) | |
tree | 687efc5e38d704c43675dd841a2ec67dc701f478 /src/command.c | |
parent | 17b6491bcf37503bbc5d6cf6cee00bd1c6ec834a (diff) | |
download | mpd-8e3c40f032d1c760b9dc11df654c577baaf5f76a.tar.gz mpd-8e3c40f032d1c760b9dc11df654c577baaf5f76a.tar.xz mpd-8e3c40f032d1c760b9dc11df654c577baaf5f76a.zip |
directory: don't pass "fd" to updateInit()
Again, move error handling to command.c.
Diffstat (limited to '')
-rw-r--r-- | src/command.c | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/src/command.c b/src/command.c index 14b1aca09..f197db393 100644 --- a/src/command.c +++ b/src/command.c @@ -816,9 +816,27 @@ static int listHandleUpdate(int fd, nextCmd = getCommandEntryFromString(next->data, permission); if (cmd != nextCmd) { - int ret = updateInit(fd, pathList); + int ret = updateInit(pathList); freeList(pathList); pathList = NULL; + + switch (ret) { + case 0: + commandError(fd, ACK_ERROR_UPDATE_ALREADY, + "already updating"); + break; + + case -1: + commandError(fd, ACK_ERROR_SYSTEM, + "problems trying to update"); + break; + + default: + fdprintf(fd, "updating_db: %i\n", ret); + ret = 0; + break; + } + return ret; } @@ -828,15 +846,35 @@ static int listHandleUpdate(int fd, static int handleUpdate(int fd, mpd_unused int *permission, mpd_unused int argc, char *argv[]) { + int ret; + if (argc == 2) { - int ret; List *pathList = makeList(NULL, 1); insertInList(pathList, argv[1], NULL); - ret = updateInit(fd, pathList); + ret = updateInit(pathList); freeList(pathList); - return ret; + } else + ret = updateInit(NULL); + + switch (ret) { + case 0: + commandError(fd, ACK_ERROR_UPDATE_ALREADY, + "already updating"); + ret = -1; + break; + + case -1: + commandError(fd, ACK_ERROR_SYSTEM, + "problems trying to update"); + break; + + default: + fdprintf(fd, "updating_db: %i\n", ret); + ret = 0; + break; } - return updateInit(fd, NULL); + + return ret; } static int handleNext(mpd_unused int fd, mpd_unused int *permission, |