lib/commit: Avoid trying to delete `.` with _CONSUME flag
authorColin Walters <walters@verbum.org>
Mon, 16 Oct 2017 19:04:48 +0000 (15:04 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Tue, 17 Oct 2017 16:24:13 +0000 (16:24 +0000)
This helps port rpm-ostree.

Closes: #1278
Approved by: jlebon

src/libostree/ostree-repo-commit.c

index 140ea34f7cb41a3a8c34096d2d0873fa4218fa4c..f0cc8bf44c3d2edf89a3c8cf36767543a3902e9f 100644 (file)
@@ -3193,11 +3193,13 @@ ostree_repo_write_dfd_to_mtree (OstreeRepo                *self,
     return FALSE;
 
   /* And now finally remove the toplevel; see also the handling for this flag in
-   * the write_dfd_iter_to_mtree_internal() function.
+   * the write_dfd_iter_to_mtree_internal() function. As a special case we don't
+   * try to remove `.` (since we'd get EINVAL); that's what's used in
+   * rpm-ostree.
    */
   const gboolean delete_after_commit = modifier &&
     (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CONSUME);
-  if (delete_after_commit)
+  if (delete_after_commit && !g_str_equal (path, "."))
     {
       if (!glnx_unlinkat (dfd, path, AT_REMOVEDIR, error))
         return FALSE;