summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2020-08-07 16:38:51 +0100
committerAlexander Larsson <alexander.larsson@gmail.com>2020-08-24 08:58:08 +0200
commit78a2e45610db3b33d198dcb03666530e60d3b5c0 (patch)
tree9f356a275b6c91d72e0434afc54b38e3dabfb69f
parent95bef8e4a5a113dd125acb3099342add46de6263 (diff)
downloadflatpak-78a2e45610db3b33d198dcb03666530e60d3b5c0.tar.gz
flatpak-dir: Pass cached summary{,.sig} to OSTree
This allows OSTree to avoid re-checking the `summary.sig` for freshness once per pull in a transaction, since flatpak has already done that. This avoids latency in a transaction (especially on high latency or lossy network connections) and avoids the potential race condition of the `summary` file changing on the server part-way through a transaction. Signed-off-by: Philip Withnall <withnall@endlessm.com>
-rw-r--r--common/flatpak-dir.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c
index 93b5c553..8e0cf5dc 100644
--- a/common/flatpak-dir.c
+++ b/common/flatpak-dir.c
@@ -4678,6 +4678,7 @@ repo_get_remote_collection_id (OstreeRepo *repo,
* collection-based and normal pulls. Update @builder in place. */
static void
get_common_pull_options (GVariantBuilder *builder,
+ FlatpakRemoteState *state,
const char *ref_to_fetch,
const char *token,
const gchar * const *dirs_to_pull,
@@ -4689,6 +4690,14 @@ get_common_pull_options (GVariantBuilder *builder,
guint32 update_interval = 0;
GVariantBuilder hdr_builder;
+ if (state->summary_bytes && state->summary_sig_bytes)
+ {
+ g_variant_builder_add (builder, "{s@v}", "summary-bytes",
+ g_variant_new_variant (g_variant_new_from_bytes (G_VARIANT_TYPE ("ay"), state->summary_bytes, TRUE)));
+ g_variant_builder_add (builder, "{s@v}", "summary-sig-bytes",
+ g_variant_new_variant (g_variant_new_from_bytes (G_VARIANT_TYPE ("ay"), state->summary_sig_bytes, TRUE)));
+ }
+
if (dirs_to_pull)
{
g_variant_builder_add (builder, "{s@v}", "subdirs",
@@ -4787,7 +4796,7 @@ repo_pull (OstreeRepo *self,
/* Pull options */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
- get_common_pull_options (&builder, ref_to_fetch, token, dirs_to_pull, current_checksum,
+ get_common_pull_options (&builder, state, ref_to_fetch, token, dirs_to_pull, current_checksum,
force_disable_deltas, flags, progress);
if (sideload_repo)