diff options
author | Matthew Leeds <matthew.leeds@endlessm.com> | 2018-04-17 13:17:33 -0700 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-04-19 20:59:34 +0000 |
commit | 79907f4236a0c51f9dd098b73f4b0685d841f601 (patch) | |
tree | 92be8eee13ddcc5ccb7c6534257ce32446b2904b /common/flatpak-dir.c | |
parent | 0bb024869a22e611873dfcdb3298a5675262c223 (diff) | |
download | flatpak-79907f4236a0c51f9dd098b73f4b0685d841f601.tar.gz |
dir: Fetch ostree-metadata independently of summary
Currently _flatpak_dir_get_remote_state() only fetches the
ostree-metadata ref if it was able to fetch the remote summary, but this
is unnecessary because we don't need to know the checksum just to fetch
it, and this is especially problematic in the offline use case when the
remote summary can't be fetched. So this commit makes flatpak fetch
ostree-metadata even if the summary fetch failed, which is consistent
with how things worked before commit fedb0e5bd.
Closes: #1587
Approved by: mwleeds
Diffstat (limited to 'common/flatpak-dir.c')
-rw-r--r-- | common/flatpak-dir.c | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index 13204c68..cc21ae85 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -8215,51 +8215,49 @@ _flatpak_dir_get_remote_state (FlatpakDir *self, } } - if (state->summary != NULL) /* In the optional case we might not have a summary */ + if (state->collection_id == NULL) + { + if (state->summary != NULL) /* In the optional case we might not have a summary */ + state->metadata = g_variant_get_child_value (state->summary, 1); + } + else { - if (state->collection_id == NULL) - { - state->metadata = g_variant_get_child_value (state->summary, 1); - } - else - { #ifdef FLATPAK_ENABLE_P2P - g_autofree char *latest_rev = NULL; - g_autoptr(GVariant) commit_v = NULL; - g_autoptr(GError) local_error = NULL; + g_autofree char *latest_rev = NULL; + g_autoptr(GVariant) commit_v = NULL; + g_autoptr(GError) local_error = NULL; - /* Make sure the branch is up to date. */ - if (!_flatpak_dir_fetch_remote_state_metadata_branch (self, state, cancellable, &local_error)) + /* Make sure the branch is up to date. */ + if (!_flatpak_dir_fetch_remote_state_metadata_branch (self, state, cancellable, &local_error)) + { + if (optional) { - if (optional) - { - /* This happens for instance in the case where a p2p remote is invalid (wrong signature) - and we should just silently fail to update to it. */ - g_debug ("Failed to download optional metadata"); - } - else - { - g_propagate_error (error, g_steal_pointer (&local_error)); - return NULL; - } + /* This happens for instance in the case where a p2p remote is invalid (wrong signature) + and we should just silently fail to update to it. */ + g_debug ("Failed to download optional metadata"); } else { - /* Look up the commit containing the latest repository metadata. */ - latest_rev = flatpak_dir_read_latest (self, remote, OSTREE_REPO_METADATA_REF, - NULL, cancellable, error); - if (latest_rev == NULL) - return NULL; + g_propagate_error (error, g_steal_pointer (&local_error)); + return NULL; + } + } + else + { + /* Look up the commit containing the latest repository metadata. */ + latest_rev = flatpak_dir_read_latest (self, remote, OSTREE_REPO_METADATA_REF, + NULL, cancellable, error); + if (latest_rev == NULL) + return NULL; - if (!ostree_repo_load_commit (self->repo, latest_rev, &commit_v, NULL, error)) - return NULL; + if (!ostree_repo_load_commit (self->repo, latest_rev, &commit_v, NULL, error)) + return NULL; - state->metadata = g_variant_get_child_value (commit_v, 0); - } + state->metadata = g_variant_get_child_value (commit_v, 0); + } #else /* if !FLATPAK_ENABLE_P2P */ - g_assert_not_reached (); + g_assert_not_reached (); #endif /* !FLATPAK_ENABLE_P2P */ - } } return g_steal_pointer (&state); @@ -10177,8 +10175,10 @@ _flatpak_dir_fetch_remote_state_metadata_branch (FlatpakDir *self, /* Look up the checksum as advertised by the summary file. If it differs from * what we currently have on disk, try and pull the updated ostree-metadata ref. * This is how we implement caching. Ignore failure and pull the ref anyway. */ - if (!flatpak_summary_lookup_ref (state->summary, state->collection_id, OSTREE_REPO_METADATA_REF, &checksum_from_summary, NULL)) - return flatpak_fail (error, "No such ref (%s, %s) in remote %s", state->collection_id, OSTREE_REPO_METADATA_REF, state->remote_name); + if (state->summary != NULL) + flatpak_summary_lookup_ref (state->summary, state->collection_id, + OSTREE_REPO_METADATA_REF, + &checksum_from_summary, NULL); refspec = g_strdup_printf ("%s:%s", state->remote_name, OSTREE_REPO_METADATA_REF); if (!ostree_repo_resolve_rev (self->repo, refspec, TRUE, &checksum_from_repo, error)) |