summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2020-10-09 10:55:52 +0200
committerAlexander Larsson <alexl@redhat.com>2020-10-23 13:06:46 +0200
commit6c8e6539e2487c5d30a18c9b89dd8d6cf4455bb7 (patch)
treeab57d864bee1f391d8ea5649a38ef93dff9112eb
parent0984ff8471cb758f66e8958813670c8ee99e7358 (diff)
downloadostree-6c8e6539e2487c5d30a18c9b89dd8d6cf4455bb7.tar.gz
deltas: Set `indexed-deltas` key in the config and summary
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.
-rw-r--r--src/libostree/ostree-repo-private.h1
-rw-r--r--src/libostree/ostree-repo-static-delta-core.c15
-rw-r--r--src/libostree/ostree-repo.c3
3 files changed, 19 insertions, 0 deletions
diff --git a/src/libostree/ostree-repo-private.h b/src/libostree/ostree-repo-private.h
index a48feca4..cbbe6971 100644
--- a/src/libostree/ostree-repo-private.h
+++ b/src/libostree/ostree-repo-private.h
@@ -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)
diff --git a/src/libostree/ostree-repo-static-delta-core.c b/src/libostree/ostree-repo-static-delta-core.c
index 5370d152..c2536724 100644
--- a/src/libostree/ostree-repo-static-delta-core.c
+++ b/src/libostree/ostree-repo-static-delta-core.c
@@ -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)
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index c22a6666..82f8db44 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -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. */
{