repo: Don't require a txn for writing

The current "transaction" symlink was introduced to fix issues with
interrupted pulls; normally we assume that if we have a metadata
object, we also have all objects to which it refers.

There used to be a "summary" which had all the available refs, but I
deleted it because it wasn't really used, and was still racy despite
the transaction bits.

We still want the pull process to use the transaction link, so don't
delete the APIs, just relax the restriction on object writing, and
introduce a new ostree_repo_set_ref_immediate().
This commit is contained in:
Colin Walters committed 2014-05-26 18:49:17 -04:00
1 parent a4d01976bb
commit f1ccaa581e
5 files changed
+65 -23

No files matched your search

+25 -2
View File
@@ -368,8 +368,6 @@ write_object (OstreeRepo *self,
gsize unpacked_size = 0;
gboolean indexable = FALSE;
g_return_val_if_fail (self->in_transaction, FALSE);
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return FALSE;
@@ -930,6 +928,31 @@ ostree_repo_transaction_set_ref (OstreeRepo *self,
g_hash_table_replace (self->txn_refs, refspec, g_strdup (checksum));
}
/**
* ostree_repo_set_ref_immediate:
* @self: An #OstreeRepo
* @remote: (allow-none): A remote for the ref
* @ref: The ref to write
* @checksum: The checksum to point it to
* @cancellable: GCancellable
* @error: GError
*
* This is like ostree_repo_transaction_set_ref(), except it may be
* invoked outside of a transaction. This is presently safe for the
* case where we're creating or overwriting an existing ref.
*/
gboolean
ostree_repo_set_ref_immediate (OstreeRepo *self,
const char *remote,
const char *ref,
const char *checksum,
GCancellable *cancellable,
GError **error)
{
return _ostree_repo_write_ref (self, remote, ref, checksum,
cancellable, error);
}
/**
* ostree_repo_commit_transaction:
* @self: An #OstreeRepo