aboutsummaryrefslogtreecommitdiffstats
path: root/src/update_walk.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-07-21 08:58:15 +0200
committerMax Kellermann <max@duempel.org>2010-07-21 09:26:50 +0200
commite598922133d11cc59994f35f62fe0f454ceb4173 (patch)
treed2bcfedb8870ceb4d18a5199ce2b06593c8926a0 /src/update_walk.c
parente21ad70f3fa183447436c5434585288d58559a46 (diff)
downloadmpd-e598922133d11cc59994f35f62fe0f454ceb4173.tar.gz
mpd-e598922133d11cc59994f35f62fe0f454ceb4173.tar.xz
mpd-e598922133d11cc59994f35f62fe0f454ceb4173.zip
update: store playlist files in database
Don't open the music directory for each "lsinfo" call. Get the list of playlist files from the memory database.
Diffstat (limited to '')
-rw-r--r--src/update_walk.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/update_walk.c b/src/update_walk.c
index b8c740ae0..bd5714def 100644
--- a/src/update_walk.c
+++ b/src/update_walk.c
@@ -28,6 +28,7 @@
#include "path.h"
#include "decoder_list.h"
#include "decoder_plugin.h"
+#include "playlist_list.h"
#include "conf.h"
#ifdef ENABLE_ARCHIVE
@@ -159,6 +160,8 @@ delete_name_in(struct directory *parent, const char *name)
delete_song(parent, song);
modified = true;
}
+
+ playlist_vector_remove(&parent->playlists, name);
}
/* passed to songvec_for_each */
@@ -244,6 +247,21 @@ directory_exists(const struct directory *directory)
return exists;
}
+static bool
+directory_child_is_regular(const struct directory *directory,
+ const char *name_utf8)
+{
+ char *path_fs = map_directory_child_fs(directory, name_utf8);
+ if (path_fs == NULL)
+ return false;
+
+ struct stat st;
+ bool is_regular = stat(path_fs, &st) == 0 && S_ISREG(st.st_mode);
+ g_free(path_fs);
+
+ return is_regular;
+}
+
static void
removeDeletedFromDirectory(struct directory *directory)
{
@@ -260,6 +278,16 @@ removeDeletedFromDirectory(struct directory *directory)
}
songvec_for_each(&directory->songs, delete_song_if_removed, directory);
+
+ for (const struct playlist_metadata *pm = directory->playlists.head;
+ pm != NULL;) {
+ const struct playlist_metadata *next = pm->next;
+
+ if (!directory_child_is_regular(directory, pm->name))
+ playlist_vector_remove(&directory->playlists, pm->name);
+
+ pm = next;
+ }
}
static int
@@ -574,6 +602,9 @@ update_regular_file(struct directory *directory,
} else if ((archive = archive_plugin_from_suffix(suffix))) {
update_archive_file(directory, name, st, archive);
#endif
+
+ } else if (playlist_suffix_supported(suffix)) {
+ playlist_vector_add(&directory->playlists, name, st->st_mtime);
}
}