lib/commit: Avoid trying to delete `.` with _CONSUME flag

This helps port rpm-ostree.

Closes: #1278
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-10-16 15:04:48 -04:00 committed by Atomic Bot
parent 93457071cb
commit bc7ff2cd1d
1 changed files with 4 additions and 2 deletions

View File

@ -3193,11 +3193,13 @@ ostree_repo_write_dfd_to_mtree (OstreeRepo *self,
return FALSE; return FALSE;
/* And now finally remove the toplevel; see also the handling for this flag in /* 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 && const gboolean delete_after_commit = modifier &&
(modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CONSUME); (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)) if (!glnx_unlinkat (dfd, path, AT_REMOVEDIR, error))
return FALSE; return FALSE;