mirror of
https://github.com/schoebel/mars
synced 2025-02-10 17:20:54 +00:00
infra: fix removal of stale directories
This commit is contained in:
parent
5d2a682cfd
commit
3acb6a02fe
@ -3837,6 +3837,10 @@ static int prepare_delete(void *buf, struct mars_dent *dent)
|
||||
MARS_WRN("target '%s' has newer timestamp than deletion link, ignoring\n", dent->new_link);
|
||||
goto ok;
|
||||
}
|
||||
if (target->d_child_count) {
|
||||
MARS_WRN("target '%s' has %d children, cannot kill\n", dent->new_link, target->d_child_count);
|
||||
goto ok;
|
||||
}
|
||||
status = mars_unlink(dent->new_link);
|
||||
target->d_killme = true;
|
||||
MARS_DBG("target '%s' deleted (status = %d) and marked for removal\n", dent->new_link, status);
|
||||
|
@ -49,6 +49,7 @@ extern char *my_id(void);
|
||||
int d_class; /* for pre-grouping order */ \
|
||||
int d_serial; /* for pre-grouping order */ \
|
||||
int d_version; /* dynamic programming per call of mars_ent_work() */ \
|
||||
int d_child_count; \
|
||||
char d_once_error; \
|
||||
bool d_killme; \
|
||||
bool d_use_channel; \
|
||||
|
@ -674,7 +674,11 @@ found:
|
||||
dent->d_type = d_type;
|
||||
dent->d_class = class;
|
||||
dent->d_serial = serial;
|
||||
if (dent->d_parent)
|
||||
dent->d_parent->d_child_count--;
|
||||
dent->d_parent = cookie->parent;
|
||||
if (dent->d_parent)
|
||||
dent->d_parent->d_child_count++;
|
||||
dent->d_depth = cookie->depth;
|
||||
dent->d_global = global;
|
||||
dent->d_killme = false;
|
||||
@ -998,6 +1002,9 @@ void mars_free_dent(struct mars_dent *dent)
|
||||
brick_string_free(dent->d_path);
|
||||
brick_string_free(dent->old_link);
|
||||
brick_string_free(dent->new_link);
|
||||
if (likely(dent->d_parent)) {
|
||||
dent->d_parent->d_child_count--;
|
||||
}
|
||||
if (dent->d_private_destruct) {
|
||||
dent->d_private_destruct(dent->d_private);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user