lib/repo: Add mode and tombstone config options to the summary file

Currently, they are set in the `config` file and cause that to be
downloaded on every pull. Given that the client is already pulling the
`summary` file, it makes sense to avoid an additional network round trip
and cache those options in the `summary` file.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #2165
This commit is contained in:
Philip Withnall 2020-08-10 12:05:06 +01:00 committed by Philip Withnall
parent a5f9651dab
commit 206f1d3a13
4 changed files with 37 additions and 1 deletions

View File

@ -55,6 +55,8 @@ G_BEGIN_DECLS
#define OSTREE_SUMMARY_EXPIRES "ostree.summary.expires"
#define OSTREE_SUMMARY_COLLECTION_ID "ostree.summary.collection-id"
#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_PAYLOAD_LINK_PREFIX "../"
#define _OSTREE_PAYLOAD_LINK_PREFIX_LEN (sizeof (_OSTREE_PAYLOAD_LINK_PREFIX) - 1)

View File

@ -5816,6 +5816,24 @@ ostree_repo_regenerate_summary (OstreeRepo *self,
g_variant_new_uint64 (GUINT64_TO_BE (g_get_real_time () / G_USEC_PER_SEC)));
}
{
g_autofree char *remote_mode_str = NULL;
if (!ot_keyfile_get_value_with_default (self->config, "core", "mode", "bare",
&remote_mode_str, error))
return FALSE;
g_variant_dict_insert_value (&additional_metadata_builder, OSTREE_SUMMARY_MODE,
g_variant_new_string (remote_mode_str));
}
{
gboolean tombstone_commits = FALSE;
if (!ot_keyfile_get_boolean_with_default (self->config, "core", "tombstone-commits", FALSE,
&tombstone_commits, error))
return FALSE;
g_variant_dict_insert_value (&additional_metadata_builder, OSTREE_SUMMARY_TOMBSTONE_COMMITS,
g_variant_new_boolean (tombstone_commits));
}
/* Add refs which have a collection specified, which could be in refs/mirrors,
* refs/heads, and/or refs/remotes. */
{

View File

@ -361,6 +361,22 @@ ot_dump_summary_bytes (GBytes *summary_bytes,
pretty_key = "Collection Map";
value_str = g_strdup ("(printed above)");
}
else if (g_strcmp0 (key, OSTREE_SUMMARY_MODE) == 0)
{
OstreeRepoMode repo_mode;
const char *repo_mode_str = g_variant_get_string (value, NULL);
pretty_key = "Repository Mode";
if (!ostree_repo_mode_from_string (repo_mode_str, &repo_mode, NULL))
value_str = g_strdup_printf ("Invalid (%s)", repo_mode_str);
else
value_str = g_strdup (repo_mode_str);
}
else if (g_strcmp0 (key, OSTREE_SUMMARY_TOMBSTONE_COMMITS) == 0)
{
pretty_key = "Has Tombstone Commits";
value_str = g_strdup (g_variant_get_boolean (value) ? "Yes" : "No");
}
else
{
value_str = g_variant_print (value, FALSE);

View File

@ -64,5 +64,5 @@ echo "ok view summary"
${OSTREE} summary --raw > raw-summary.txt
assert_file_has_content_literal raw-summary.txt "('main', ("
assert_file_has_content_literal raw-summary.txt "('other', ("
assert_file_has_content_literal raw-summary.txt "{'ostree.summary.last-modified': <uint64"
assert_file_has_content_literal raw-summary.txt "'ostree.summary.last-modified': <uint64"
echo "ok view summary raw"