diff options
author | Max Kellermann <max@duempel.org> | 2014-07-29 23:29:57 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-07-29 23:29:57 +0200 |
commit | 0c47685e0291b835034b7f5855eafef9bf69c7c9 (patch) | |
tree | fe5c9e084b8e21c83a750122abf07623771fc5d7 /src/command/OtherCommands.cxx | |
parent | e0ca4347beb2e2e7235e16c4555d426c7d923468 (diff) | |
download | mpd-0c47685e0291b835034b7f5855eafef9bf69c7c9.tar.gz mpd-0c47685e0291b835034b7f5855eafef9bf69c7c9.tar.xz mpd-0c47685e0291b835034b7f5855eafef9bf69c7c9.zip |
OtherCommands: split handle_update()
Diffstat (limited to '')
-rw-r--r-- | src/command/OtherCommands.cxx | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/src/command/OtherCommands.cxx b/src/command/OtherCommands.cxx index c9b8a46f3..4f149e58e 100644 --- a/src/command/OtherCommands.cxx +++ b/src/command/OtherCommands.cxx @@ -225,6 +225,25 @@ handle_lsinfo(Client &client, unsigned argc, char *argv[]) return CommandResult::OK; } +#ifdef ENABLE_DATABASE + +static CommandResult +handle_update(Client &client, UpdateService &update, + const char *uri_utf8, bool discard) +{ + unsigned ret = update.Enqueue(uri_utf8, discard); + if (ret > 0) { + client_printf(client, "updating_db: %i\n", ret); + return CommandResult::OK; + } else { + command_error(client, ACK_ERROR_UPDATE_ALREADY, + "already updating"); + return CommandResult::ERROR; + } +} + +#endif + static CommandResult handle_update(Client &client, unsigned argc, char *argv[], bool discard) { @@ -246,29 +265,16 @@ handle_update(Client &client, unsigned argc, char *argv[], bool discard) } UpdateService *update = client.partition.instance.update; - if (update == nullptr) { - command_error(client, ACK_ERROR_NO_EXIST, "No database"); - return CommandResult::ERROR; - } - - unsigned ret = update->Enqueue(path, discard); - if (ret > 0) { - client_printf(client, "updating_db: %i\n", ret); - return CommandResult::OK; - } else { - command_error(client, ACK_ERROR_UPDATE_ALREADY, - "already updating"); - return CommandResult::ERROR; - } + if (update != nullptr) + return handle_update(client, *update, path, discard); #else - (void)client; (void)argc; (void)argv; (void)discard; +#endif command_error(client, ACK_ERROR_NO_EXIST, "No database"); return CommandResult::ERROR; -#endif } CommandResult |