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.
This commit is contained in:
Alexander Larsson 2020-10-09 10:55:52 +02:00
parent 0984ff8471
commit 6c8e6539e2
3 changed files with 19 additions and 0 deletions

View 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)

View 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)

View 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. */
{