mirror of
https://github.com/systemd/systemd.git
synced 2025-02-03 17:47:28 +03:00
tmpfiles: honour --dry-run when removing directories
(cherry picked from commit edeceb80a91e8400e8c22f08a41045a2ba270fe6)
This commit is contained in:
parent
c26e56d08f
commit
90ec026570
@ -3024,10 +3024,16 @@ static int remove_recursive(
|
||||
return r;
|
||||
|
||||
if (remove_instance) {
|
||||
log_debug("Removing directory \"%s\".", instance);
|
||||
r = RET_NERRNO(rmdir(instance));
|
||||
if (r < 0 && !IN_SET(r, -ENOENT, -ENOTEMPTY))
|
||||
return log_error_errno(r, "Failed to remove %s: %m", instance);
|
||||
log_action("Would remove", "Removing", "%s directory \"%s\".", instance);
|
||||
if (!arg_dry_run) {
|
||||
r = RET_NERRNO(rmdir(instance));
|
||||
if (r < 0) {
|
||||
bool fatal = !IN_SET(r, -ENOENT, -ENOTEMPTY);
|
||||
log_full_errno(fatal ? LOG_ERR : LOG_DEBUG, r, "Failed to remove %s: %m", instance);
|
||||
if (fatal)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user