[ostree] deltas: Support including detached metadata in static deltas



commit 1c056eb282d3ebfc45e2dffd7af9d046598f4ee2
Author: Alexander Larsson <alexl redhat com>
Date:   Mon Oct 19 10:10:50 2015 +0200

    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.

 src/libostree/ostree-repo-pull.c                   |   14 +++++++++++++-
 .../ostree-repo-static-delta-compilation.c         |   11 ++++++++++-
 src/libostree/ostree-repo-static-delta-core.c      |   14 +++++++++++++-
 3 files changed, 36 insertions(+), 3 deletions(-)
---
diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c
index 4c3b14b..76cd027 100644
--- a/src/libostree/ostree-repo-pull.c
+++ b/src/libostree/ostree-repo-pull.c
@@ -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;
diff --git a/src/libostree/ostree-repo-static-delta-compilation.c 
b/src/libostree/ostree-repo-static-delta-compilation.c
index d051d01..530b3a7 100644
--- a/src/libostree/ostree-repo-static-delta-compilation.c
+++ b/src/libostree/ostree-repo-static-delta-compilation.c
@@ -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 ();
diff --git a/src/libostree/ostree-repo-static-delta-core.c b/src/libostree/ostree-repo-static-delta-core.c
index 2e44578..e3490fd 100644
--- a/src/libostree/ostree-repo-static-delta-core.c
+++ b/src/libostree/ostree-repo-static-delta-core.c
@@ -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++)
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]