aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-09-13 20:38:12 +0200
committerMax Kellermann <max@duempel.org>2011-09-13 20:44:35 +0200
commit412cf974a4cf3693cc643ab8ce0c1d733b7e8047 (patch)
tree05ad662892dd364b6c3466dfc860270cb4c8d944
parent3fc6beeff0c5bba90a458422c40af5ed0d6c81aa (diff)
downloadmpd-412cf974a4cf3693cc643ab8ce0c1d733b7e8047.tar.gz
mpd-412cf974a4cf3693cc643ab8ce0c1d733b7e8047.tar.xz
mpd-412cf974a4cf3693cc643ab8ce0c1d733b7e8047.zip
directory: don't visit "self" in _walk()
Let the caller decide if the current directory should be visited.
Diffstat (limited to '')
-rw-r--r--src/database.c4
-rw-r--r--src/directory.c8
2 files changed, 8 insertions, 4 deletions
diff --git a/src/database.c b/src/database.c
index 6d7cc3e23..d93066389 100644
--- a/src/database.c
+++ b/src/database.c
@@ -128,6 +128,10 @@ db_walk(const char *uri,
return false;
}
+ if (visitor->directory != NULL &&
+ !visitor->directory(directory, ctx, error_r))
+ return false;
+
return directory_walk(directory, visitor, ctx, error_r);
}
diff --git a/src/directory.c b/src/directory.c
index 515b07e7d..83fefb8c4 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -177,10 +177,6 @@ directory_walk(struct directory *directory,
assert(visitor != NULL);
assert(error_r == NULL || *error_r == NULL);
- if (visitor->directory != NULL &&
- !visitor->directory(directory, ctx, error_r))
- return false;
-
if (visitor->song != NULL) {
struct songvec *sv = &directory->songs;
for (size_t i = 0; i < sv->nr; ++i)
@@ -192,6 +188,10 @@ directory_walk(struct directory *directory,
for (size_t i = 0; i < dv->nr; ++i) {
struct directory *child = dv->base[i];
+ if (visitor->directory != NULL &&
+ !visitor->directory(child, ctx, error_r))
+ return false;
+
if (!directory_walk(child, visitor, ctx, error_r))
return false;
}