aboutsummaryrefslogtreecommitdiffstats
path: root/src/update_queue.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/update_queue.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 '')
-rw-r--r--src/update_queue.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/update_queue.c b/src/update_queue.c
index ef1753c21..60e752a62 100644
--- a/src/update_queue.c
+++ b/src/update_queue.c
@@ -25,31 +25,41 @@
#include <string.h>
/* make this dynamic?, or maybe this is big enough... */
-static char *update_paths[32];
-static size_t update_paths_nr;
+static struct {
+ char *path;
+ bool discard;
+} update_queue[32];
+
+static size_t update_queue_length;
unsigned
-update_queue_push(const char *path, unsigned base)
+update_queue_push(const char *path, bool discard, unsigned base)
{
- assert(update_paths_nr <= G_N_ELEMENTS(update_paths));
+ assert(update_queue_length <= G_N_ELEMENTS(update_queue));
- if (update_paths_nr == G_N_ELEMENTS(update_paths))
+ if (update_queue_length == G_N_ELEMENTS(update_queue))
return 0;
- update_paths[update_paths_nr++] = g_strdup(path);
- return base + update_paths_nr;
+ update_queue[update_queue_length].path = g_strdup(path);
+ update_queue[update_queue_length].discard = discard;
+
+ ++update_queue_length;
+
+ return base + update_queue_length;
}
char *
-update_queue_shift(void)
+update_queue_shift(bool *discard_r)
{
char *path;
- if (update_paths_nr == 0)
+ if (update_queue_length == 0)
return NULL;
- path = update_paths[0];
- memmove(&update_paths[0], &update_paths[1],
- --update_paths_nr * sizeof(char *));
+ path = update_queue[0].path;
+ *discard_r = update_queue[0].discard;
+
+ memmove(&update_queue[0], &update_queue[1],
+ --update_queue_length * sizeof(update_queue[0]));
return path;
}