aboutsummaryrefslogtreecommitdiffstats
path: root/src/update_walk.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_walk.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/update_walk.c')
-rw-r--r--src/update_walk.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/update_walk.c b/src/update_walk.c
index 967795cff..b79e95ae0 100644
--- a/src/update_walk.c
+++ b/src/update_walk.c
@@ -39,6 +39,7 @@
#include <stdlib.h>
#include <errno.h>
+static bool walk_discard;
static bool modified;
#ifndef WIN32
@@ -350,7 +351,8 @@ update_archive_file(struct directory *parent, const char *name,
char *filepath;
directory = dirvec_find(&parent->children, name);
- if (directory != NULL && directory->mtime == st->st_mtime)
+ if (directory != NULL && directory->mtime == st->st_mtime &&
+ !walk_discard)
/* MPD has already scanned the archive, and it hasn't
changed since - don't consider updating it */
return;
@@ -405,7 +407,7 @@ update_container_file( struct directory* directory,
if (contdir != NULL)
{
// modification time not eq. file mod. time
- if (contdir->mtime != st->st_mtime)
+ if (contdir->mtime != st->st_mtime || walk_discard)
{
g_message("removing container file: %s", pathname);
@@ -470,7 +472,8 @@ update_regular_file(struct directory *directory,
{
struct song* song = songvec_find(&directory->songs, name);
- if (!(song != NULL && st->st_mtime == song->mtime) &&
+ if (!(song != NULL && st->st_mtime == song->mtime &&
+ !walk_discard) &&
plugin->container_scan != NULL)
{
if (update_container_file(directory, name, st, plugin))
@@ -491,7 +494,7 @@ update_regular_file(struct directory *directory,
modified = true;
g_message("added %s/%s",
directory_get_path(directory), name);
- } else if (st->st_mtime != song->mtime) {
+ } else if (st->st_mtime != song->mtime || walk_discard) {
g_message("updating %s/%s",
directory_get_path(directory), name);
if (!song_file_update(song))
@@ -737,8 +740,9 @@ updatePath(const char *path)
}
bool
-update_walk(const char *path)
+update_walk(const char *path, bool discard)
{
+ walk_discard = discard;
modified = false;
if (path != NULL && !isRootDirectory(path)) {