directory: don't visit "self" in _walk()
Let the caller decide if the current directory should be visited.
This commit is contained in:
parent
3fc6beeff0
commit
412cf974a4
|
@ -128,6 +128,10 @@ db_walk(const char *uri,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (visitor->directory != NULL &&
|
||||||
|
!visitor->directory(directory, ctx, error_r))
|
||||||
|
return false;
|
||||||
|
|
||||||
return directory_walk(directory, visitor, ctx, error_r);
|
return directory_walk(directory, visitor, ctx, error_r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,10 +177,6 @@ directory_walk(struct directory *directory,
|
||||||
assert(visitor != NULL);
|
assert(visitor != NULL);
|
||||||
assert(error_r == NULL || *error_r == NULL);
|
assert(error_r == NULL || *error_r == NULL);
|
||||||
|
|
||||||
if (visitor->directory != NULL &&
|
|
||||||
!visitor->directory(directory, ctx, error_r))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (visitor->song != NULL) {
|
if (visitor->song != NULL) {
|
||||||
struct songvec *sv = &directory->songs;
|
struct songvec *sv = &directory->songs;
|
||||||
for (size_t i = 0; i < sv->nr; ++i)
|
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) {
|
for (size_t i = 0; i < dv->nr; ++i) {
|
||||||
struct directory *child = dv->base[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))
|
if (!directory_walk(child, visitor, ctx, error_r))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue