mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-19 22:50:35 +03:00
deltas: Support including detached metadata in static deltas
This is very useful for the inline-parts case, as you can then include detached signatures in a single file representing the commit. It is not as important for the generic pull case, as the detached metadata is only a single small file. Additionally the detached metadata is not content referenced and may change after the static delta file was created, so we need to pull the latest version anyway.
This commit is contained in:
parent
598afd5030
commit
1c056eb282
@ -1532,7 +1532,19 @@ process_one_static_delta (OtPullData *pull_data,
|
||||
|
||||
if (!have_to_commit)
|
||||
{
|
||||
FetchObjectData *fetch_data = g_new0 (FetchObjectData, 1);
|
||||
FetchObjectData *fetch_data;
|
||||
g_autofree char *detached_path = _ostree_get_relative_static_delta_path (from_revision, to_revision, "commitmeta");
|
||||
g_autoptr(GVariant) detached_data = NULL;
|
||||
|
||||
detached_data = g_variant_lookup_value (metadata, detached_path, G_VARIANT_TYPE("a{sv}"));
|
||||
if (detached_data && !ostree_repo_write_commit_detached_metadata (pull_data->repo,
|
||||
to_revision,
|
||||
detached_data,
|
||||
cancellable,
|
||||
error))
|
||||
goto out;
|
||||
|
||||
fetch_data = g_new0 (FetchObjectData, 1);
|
||||
fetch_data->pull_data = pull_data;
|
||||
fetch_data->object = ostree_object_name_serialize (to_checksum, OSTREE_OBJECT_TYPE_COMMIT);
|
||||
fetch_data->is_detached_meta = FALSE;
|
||||
|
@ -1260,9 +1260,9 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
||||
g_autoptr(GFile) descriptor_dir = NULL;
|
||||
g_autoptr(GVariant) tmp_metadata = NULL;
|
||||
g_autoptr(GVariant) fallback_headers = NULL;
|
||||
g_autoptr(GVariant) detached = NULL;
|
||||
gboolean inline_parts;
|
||||
g_autoptr(GFile) tmp_dir = NULL;
|
||||
|
||||
builder.parts = g_ptr_array_new_with_free_func ((GDestroyNotify)ostree_static_delta_part_builder_unref);
|
||||
builder.fallback_objects = g_ptr_array_new_with_free_func ((GDestroyNotify)g_variant_unref);
|
||||
|
||||
@ -1465,6 +1465,15 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_repo_read_commit_detached_metadata (self, to, &detached, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (detached)
|
||||
{
|
||||
g_autofree char *detached_key = _ostree_get_relative_static_delta_path (from, to, "commitmeta");
|
||||
g_variant_builder_add (&metadata_builder, "{sv}", detached_key, detached);
|
||||
}
|
||||
|
||||
/* Generate OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT */
|
||||
{
|
||||
GDateTime *now = g_date_time_new_now_utc ();
|
||||
|
@ -254,6 +254,8 @@ ostree_repo_static_delta_execute_offline (OstreeRepo *self,
|
||||
|
||||
/* Parsing OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT */
|
||||
|
||||
metadata = g_variant_get_child_value (meta, 0);
|
||||
|
||||
/* Write the to-commit object */
|
||||
{
|
||||
g_autoptr(GVariant) to_csum_v = NULL;
|
||||
@ -292,6 +294,17 @@ ostree_repo_static_delta_execute_offline (OstreeRepo *self,
|
||||
|
||||
if (!have_to_commit)
|
||||
{
|
||||
g_autofree char *detached_path = _ostree_get_relative_static_delta_path (from_checksum, to_checksum, "commitmeta");
|
||||
g_autoptr(GVariant) detached_data = NULL;
|
||||
|
||||
detached_data = g_variant_lookup_value (metadata, detached_path, G_VARIANT_TYPE("a{sv}"));
|
||||
if (detached_data && !ostree_repo_write_commit_detached_metadata (self,
|
||||
to_checksum,
|
||||
detached_data,
|
||||
cancellable,
|
||||
error))
|
||||
goto out;
|
||||
|
||||
to_commit = g_variant_get_child_value (meta, 4);
|
||||
if (!ostree_repo_write_metadata (self, OSTREE_OBJECT_TYPE_COMMIT,
|
||||
to_checksum, to_commit, NULL,
|
||||
@ -309,7 +322,6 @@ ostree_repo_static_delta_execute_offline (OstreeRepo *self,
|
||||
}
|
||||
|
||||
headers = g_variant_get_child_value (meta, 6);
|
||||
metadata = g_variant_get_child_value (meta, 0);
|
||||
n = g_variant_n_children (headers);
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user