]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
edit-util: log unexpected errors if we fail to remove the parent dir 26831/head
authorMike Yuan <me@yhndnzj.com>
Wed, 15 Mar 2023 11:38:19 +0000 (19:38 +0800)
committerMike Yuan <me@yhndnzj.com>
Wed, 15 Mar 2023 11:50:26 +0000 (19:50 +0800)
src/shared/edit-util.c

index 195075ba975d1e1ad49437c63ab843861db775d2..58cd7fe9f3dae64b36fa995bdd99b30423f2898b 100644 (file)
@@ -32,8 +32,8 @@ void edit_file_context_done(EditFileContext *context) {
                         r = path_extract_directory(i->path, &parent);
                         if (r < 0)
                                 log_debug_errno(r, "Failed to extract directory from '%s', ignoring: %m", i->path);
-                        else /* No need to check if the dir is empty, rmdir does nothing if it is not the case. */
-                            (void) rmdir(parent);
+                        else if (rmdir(parent) < 0 && !IN_SET(errno, ENOENT, ENOTEMPTY))
+                                log_debug_errno(errno, "Failed to remove parent directory '%s', ignoring: %m", parent);
                 }
 
                 free(i->path);