aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/update.c35
1 files changed, 8 insertions, 27 deletions
diff --git a/src/update.c b/src/update.c
index a1e33ba22..69ae9794d 100644
--- a/src/update.c
+++ b/src/update.c
@@ -219,23 +219,6 @@ static enum update_return
updateDirectory(struct directory *directory, const struct stat *st);
static enum update_return
-addSubDirectoryToDirectory(struct directory *directory,
- const char *name, const struct stat *st)
-{
- struct directory *subDirectory;
-
- subDirectory = directory_new(name, directory);
- if (updateDirectory(subDirectory, st) != UPDATE_RETURN_UPDATED) {
- directory_free(subDirectory);
- return UPDATE_RETURN_NOUPDATE;
- }
-
- dirvec_add(&directory->children, subDirectory);
-
- return UPDATE_RETURN_UPDATED;
-}
-
-static enum update_return
updateInDirectory(struct directory *directory,
const char *name, const struct stat *st)
{
@@ -257,23 +240,21 @@ updateInDirectory(struct directory *directory,
}
} else if (S_ISDIR(st->st_mode)) {
struct directory *subdir;
+ enum update_return ret;
if (inodeFoundInParent(directory, st->st_ino, st->st_dev))
return UPDATE_RETURN_ERROR;
- if ((subdir = directory_get_child(directory, name))) {
- enum update_return ret;
+ if (!(subdir = directory_get_child(directory, name)))
+ subdir = directory_new_child(directory, name);
- assert(directory == subdir->parent);
+ assert(directory == subdir->parent);
- ret = updateDirectory(subdir, st);
- if (ret == UPDATE_RETURN_ERROR)
- delete_directory(subdir);
+ ret = updateDirectory(subdir, st);
+ if (ret == UPDATE_RETURN_ERROR || directory_is_empty(subdir))
+ delete_directory(subdir);
- return ret;
- } else {
- return addSubDirectoryToDirectory(directory, name, st);
- }
+ return ret;
}
DEBUG("update: %s is not a directory or music\n", name);