OtherCommands: split handle_update()
This commit is contained in:
parent
e0ca4347be
commit
0c47685e02
@ -225,6 +225,25 @@ handle_lsinfo(Client &client, unsigned argc, char *argv[])
|
|||||||
return CommandResult::OK;
|
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
|
static CommandResult
|
||||||
handle_update(Client &client, unsigned argc, char *argv[], bool discard)
|
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;
|
UpdateService *update = client.partition.instance.update;
|
||||||
if (update == nullptr) {
|
if (update != nullptr)
|
||||||
command_error(client, ACK_ERROR_NO_EXIST, "No database");
|
return handle_update(client, *update, path, discard);
|
||||||
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;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
(void)client;
|
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
(void)discard;
|
(void)discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
command_error(client, ACK_ERROR_NO_EXIST, "No database");
|
command_error(client, ACK_ERROR_NO_EXIST, "No database");
|
||||||
return CommandResult::ERROR;
|
return CommandResult::ERROR;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult
|
CommandResult
|
||||||
|
Loading…
Reference in New Issue
Block a user