aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-09-24 21:55:40 +0200
committerMax Kellermann <max@duempel.org>2009-09-24 21:55:40 +0200
commit89ba540e6d76aae0a594daebb9db8524ea3ed528 (patch)
treeb9b9dda03556ceeb98f620255c9148098d178da7 /src/command.c
parent47ab2ad6f375e9f3afe2efe6a1da70ce98cec52b (diff)
downloadmpd-89ba540e6d76aae0a594daebb9db8524ea3ed528.tar.gz
mpd-89ba540e6d76aae0a594daebb9db8524ea3ed528.tar.xz
mpd-89ba540e6d76aae0a594daebb9db8524ea3ed528.zip
command: added command "rescan"
"rescan" is the same as "update", but it discards existing songs in the database.
Diffstat (limited to 'src/command.c')
-rw-r--r--src/command.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/command.c b/src/command.c
index 8298a4048..7c2743975 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1025,7 +1025,28 @@ handle_update(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
if (argc == 2)
path = argv[1];
- ret = update_enqueue(path);
+ ret = update_enqueue(path, false);
+ if (ret > 0) {
+ client_printf(client, "updating_db: %i\n", ret);
+ return COMMAND_RETURN_OK;
+ } else {
+ command_error(client, ACK_ERROR_UPDATE_ALREADY,
+ "already updating");
+ return COMMAND_RETURN_ERROR;
+ }
+}
+
+static enum command_return
+handle_rescan(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
+{
+ const char *path = NULL;
+ unsigned ret;
+
+ assert(argc <= 2);
+ if (argc == 2)
+ path = argv[1];
+
+ ret = update_enqueue(path, true);
if (ret > 0) {
client_printf(client, "updating_db: %i\n", ret);
return COMMAND_RETURN_OK;
@@ -1731,6 +1752,7 @@ static const struct command commands[] = {
{ "random", PERMISSION_CONTROL, 1, 1, handle_random },
{ "rename", PERMISSION_CONTROL, 2, 2, handle_rename },
{ "repeat", PERMISSION_CONTROL, 1, 1, handle_repeat },
+ { "rescan", PERMISSION_ADMIN, 0, 1, handle_rescan },
{ "rm", PERMISSION_CONTROL, 1, 1, handle_rm },
{ "save", PERMISSION_CONTROL, 1, 1, handle_save },
{ "search", PERMISSION_READ, 2, -1, handle_search },