deltas: Set `indexed-deltas` key in the config and summary
authorAlexander Larsson <alexl@redhat.com>
Fri, 9 Oct 2020 08:55:52 +0000 (10:55 +0200)
committerAlexander Larsson <alexl@redhat.com>
Fri, 23 Oct 2020 11:06:46 +0000 (13:06 +0200)
Clients can use these during pull and avoid downloading the summary if
needed, or use the indexed-deltas instead of relying on the ones in
the summary which may be left out.

src/libostree/ostree-repo-private.h
src/libostree/ostree-repo-static-delta-core.c
src/libostree/ostree-repo.c

index a48feca4076f999ee1af19a717a1e03b167fe6c1..cbbe69717dc22f8a4a99bc15ded0c40bbe4fb78a 100644 (file)
@@ -57,6 +57,7 @@ G_BEGIN_DECLS
 #define OSTREE_SUMMARY_COLLECTION_MAP "ostree.summary.collection-map"
 #define OSTREE_SUMMARY_MODE "ostree.summary.mode"
 #define OSTREE_SUMMARY_TOMBSTONE_COMMITS "ostree.summary.tombstone-commits"
+#define OSTREE_SUMMARY_INDEXED_DELTAS "ostree.summary.indexed-deltas"
 
 #define _OSTREE_PAYLOAD_LINK_PREFIX "../"
 #define _OSTREE_PAYLOAD_LINK_PREFIX_LEN (sizeof (_OSTREE_PAYLOAD_LINK_PREFIX) - 1)
index 5370d1520a648861b01c4f52082e4e3cce55f9cb..c253672489d7afb4c509cf292c1a10c9ad0a4bca 100644 (file)
@@ -1264,6 +1264,7 @@ ostree_repo_static_delta_reindex (OstreeRepo                 *repo,
 {
   g_autoptr(GPtrArray) all_deltas = NULL;
   g_autoptr(GHashTable) deltas_to_commit_ht = NULL; /* map: to checksum -> ptrarray of from checksums (or NULL) */
+  gboolean opt_indexed_deltas;
 
   /* Protect against parallel prune operation */
   g_autoptr(OstreeRepoAutoLock) lock =
@@ -1271,6 +1272,20 @@ ostree_repo_static_delta_reindex (OstreeRepo                 *repo,
   if (!lock)
     return FALSE;
 
+  /* Enusre that the "indexed-deltas" option is set on the config, so we know this when pulling */
+  if (!ot_keyfile_get_boolean_with_default (repo->config, "core",
+                                            "indexed-deltas", FALSE,
+                                            &opt_indexed_deltas, error))
+    return FALSE;
+
+  if (!opt_indexed_deltas)
+    {
+      g_autoptr(GKeyFile) config = ostree_repo_copy_config (repo);
+      g_key_file_set_boolean (config, "core", "indexed-deltas", TRUE);
+      if (!ostree_repo_write_config (repo, config, error))
+        return FALSE;
+    }
+
   deltas_to_commit_ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)null_or_ptr_array_unref);
 
   if (opt_to_commit == NULL)
index c22a6666c6e58091d1d6ed50d051fe0398d71c80..82f8db44363be3aa8abf61760fba1b216b89f421 100644 (file)
@@ -5842,6 +5842,9 @@ ostree_repo_regenerate_summary (OstreeRepo     *self,
                                  g_variant_new_boolean (tombstone_commits));
   }
 
+  g_variant_dict_insert_value (&additional_metadata_builder, OSTREE_SUMMARY_INDEXED_DELTAS,
+                               g_variant_new_boolean (TRUE));
+
   /* Add refs which have a collection specified, which could be in refs/mirrors,
    * refs/heads, and/or refs/remotes. */
   {