From 89ba540e6d76aae0a594daebb9db8524ea3ed528 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 24 Sep 2009 21:55:40 +0200 Subject: command: added command "rescan" "rescan" is the same as "update", but it discards existing songs in the database. --- src/update_queue.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'src/update_queue.c') 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 /* 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; } -- cgit v1.2.3