aboutsummaryrefslogtreecommitdiffstats
path: root/src/update.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-13 16:55:55 +0200
committerMax Kellermann <max@duempel.org>2008-10-13 16:55:55 +0200
commit94a5a5a985ab0ce3d8ca72d4e5be28a71a1010e0 (patch)
tree52dfb43c02d50215db72fce9575923f9ec291eba /src/update.c
parenta52343732b31849e1540e1c97f0d8e5c1b300828 (diff)
downloadmpd-94a5a5a985ab0ce3d8ca72d4e5be28a71a1010e0.tar.gz
mpd-94a5a5a985ab0ce3d8ca72d4e5be28a71a1010e0.tar.xz
mpd-94a5a5a985ab0ce3d8ca72d4e5be28a71a1010e0.zip
update: always look up parent directory in updatePath()
By always creating the parent directory, we can use delete_name_in() without further lookups. The parents which may non exist will be pruned later. An update request for a non-existing or empty directory should be quite unusual, so this doesn't add any measurable overhead.
Diffstat (limited to 'src/update.c')
-rw-r--r--src/update.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/update.c b/src/update.c
index 0219dad56..93ba1668c 100644
--- a/src/update.c
+++ b/src/update.c
@@ -162,23 +162,6 @@ delete_song_if_removed(struct song *song, void *_data)
}
static void
-delete_path(const char *path)
-{
- struct directory *directory = db_get_directory(path);
- struct song *song = db_get_song(path);
-
- if (directory != NULL) {
- delete_directory(directory);
- modified = true;
- }
-
- if (song != NULL) {
- delete_song(song->parent, song);
- modified = true;
- }
-}
-
-static void
removeDeletedFromDirectory(char *path_max_tmp, struct directory *directory)
{
int i;
@@ -405,13 +388,20 @@ addParentPathToDB(const char *utf8path)
static void
updatePath(const char *path)
{
+ struct directory *parent;
+ const char *name;
struct stat st;
+ parent = addParentPathToDB(path);
+ if (parent == NULL)
+ return;
+
+ name = mpd_basename(path);
+
if (myStat(path, &st) == 0)
- updateInDirectory(addParentPathToDB(path),
- mpd_basename(path), &st);
+ updateInDirectory(parent, name, &st);
else
- delete_path(path);
+ delete_name_in(parent, name);
}
static void * update_task(void *_path)