extra-data: Simplify extra-data progress setup

We need to get the commit object to setup the extra-data progress information,
and this is currently done using a complex pull operation to a temporary
repo. According to https://github.com/flatpak/flatpak/issues/3515 it
even causes an unecessary download of the summary in some cases.

Now that we don't need to support p2p we can instead directly download
the commit object using a simple http operation (or from the sideload
repos), as we know the commit id at this point anyway.
This commit is contained in:
Alexander Larsson
2020-03-30 13:24:15 +02:00
parent d20a8ccdfd
commit 6deb23a322

View File

@@ -4611,40 +4611,11 @@ flatpak_dir_setup_extra_data (FlatpakDir *self,
/* ostree-metadata and appstreams never have extra data, so ignore those */
if (g_str_has_prefix (ref, "app/") || g_str_has_prefix (ref, "runtime/"))
{
extra_data_sources = flatpak_repo_get_extra_data_sources (repo, rev, cancellable, NULL);
if (extra_data_sources == NULL)
{
/* This is a gigantic hack where we download the commit in a temporary transaction
* which we then abort after having read the result. We do this to avoid creating
* a partial commit in the local repo and a ref that points to it, because that
* causes ostree to not use static deltas.
* See https://github.com/flatpak/flatpak/issues/3412 for details.
*/
g_autoptr(GVariant) commitv = flatpak_remote_state_load_ref_commit (state, self, ref, rev, error);
if (commitv == NULL)
return FALSE;
if (!ostree_repo_prepare_transaction (repo, NULL, cancellable, error))
return FALSE;
/* Pull the commits (and only the commits) to check for extra data
* again. Here we don't pass the progress because we don't want any
* reports coming out of it. */
if (!repo_pull (repo, state,
NULL,
ref,
rev,
sideload_repo,
token,
flatpak_flags,
OSTREE_REPO_PULL_FLAGS_COMMIT_ONLY,
NULL,
cancellable,
error))
return FALSE;
extra_data_sources = flatpak_repo_get_extra_data_sources (repo, rev, cancellable, NULL);
if (!ostree_repo_abort_transaction (repo, cancellable, error))
return FALSE;
}
extra_data_sources = flatpak_commit_get_extra_data_sources (commitv, NULL);
}
n_extra_data = 0;