lib/commit: Move txn stagedir deletion/unlock into one place
authorColin Walters <walters@verbum.org>
Tue, 28 Nov 2017 18:01:46 +0000 (13:01 -0500)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 1 Dec 2017 19:00:18 +0000 (19:00 +0000)
Previously we'd delete the tmpdir in `rename_pending_loose_objects()`
but do the unlock inside `ostree_repo_commit_transaction()`.  Move
them into the same place in the latter function for consistency.

Doesn't fix anything, just a cleanup while reading the code and
working on `test-concurrency.py`.

Closes: #1352
Approved by: dbnicholson

src/libostree/ostree-repo-commit.c

index 85e2e89126c286878062aa6be3f68f81fd58e9c9..e2fdf9f4f0f03b111a17dea763fe8be0356d21ef 100644 (file)
@@ -1435,9 +1435,6 @@ rename_pending_loose_objects (OstreeRepo        *self,
         return glnx_throw_errno_prefix (error, "fsync");
     }
 
-  if (!glnx_tmpdir_delete (&self->commit_stagedir, cancellable, error))
-    return FALSE;
-
   return TRUE;
 }
 
@@ -1773,6 +1770,12 @@ ostree_repo_commit_transaction (OstreeRepo                  *self,
   if (!rename_pending_loose_objects (self, cancellable, error))
     return FALSE;
 
+  g_debug ("txn commit %s", glnx_basename (self->commit_stagedir.path));
+  if (!glnx_tmpdir_delete (&self->commit_stagedir, cancellable, error))
+    return FALSE;
+  glnx_release_lock_file (&self->commit_stagedir_lock);
+
+  /* This performs a global cleanup */
   if (!cleanup_tmpdir (self, cancellable, error))
     return FALSE;
 
@@ -1789,9 +1792,6 @@ ostree_repo_commit_transaction (OstreeRepo                  *self,
       return FALSE;
   g_clear_pointer (&self->txn_collection_refs, g_hash_table_destroy);
 
-  glnx_tmpdir_unset (&self->commit_stagedir);
-  glnx_release_lock_file (&self->commit_stagedir_lock);
-
   self->in_transaction = FALSE;
 
   if (!ot_ensure_unlinked_at (self->repo_dir_fd, "transaction", 0))