Commit 8536a979 authored by Max Kellermann's avatar Max Kellermann

update: delete directory after failed update

When a directory cannot be updated, there must be something wrong with it, and the database contains stale data. Remove it.
parent 0daba6bd
...@@ -254,9 +254,16 @@ updateInDirectory(struct directory *directory, const char *name) ...@@ -254,9 +254,16 @@ updateInDirectory(struct directory *directory, const char *name)
} else if (S_ISDIR(st.st_mode)) { } else if (S_ISDIR(st.st_mode)) {
struct directory *subdir = directory_get_child(directory, name); struct directory *subdir = directory_get_child(directory, name);
if (subdir) { if (subdir) {
enum update_return ret;
assert(directory == subdir->parent); assert(directory == subdir->parent);
directory_set_stat(subdir, &st); directory_set_stat(subdir, &st);
return updateDirectory(subdir);
ret = updateDirectory(subdir);
if (ret == UPDATE_RETURN_ERROR)
delete_directory(subdir);
return ret;
} else { } else {
return addSubDirectoryToDirectory(directory, name, &st); return addSubDirectoryToDirectory(directory, name, &st);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment