command: added command "rescan"

"rescan" is the same as "update", but it discards existing songs in
the database.
This commit is contained in:
Max Kellermann
2009-09-24 21:55:40 +02:00
parent 47ab2ad6f3
commit 89ba540e6d
8 changed files with 81 additions and 27 deletions
+9 -5
View File
@@ -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)) {