libpriv/core: Check cancellable before/after downloading rpm-md

This is a quick band-aid to improve Ctrl-C handling in this area:
https://github.com/projectatomic/rpm-ostree/issues/897

At least this way we'll exit earlier rather than waiting until all the repos are
downloaded (and imported into libsolv, which is itself slow).

Closes: #1018
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-09-28 13:31:41 -04:00 committed by Atomic Bot
parent fd6109af1d
commit c0ef5eec4f

View File

@ -939,6 +939,10 @@ rpmostree_context_download_metadata (RpmOstreeContext *self,
DnfRepo *repo = rpmmd_repos->pdata[i];
g_autoptr(DnfState) hifstate = dnf_state_new ();
/* Until libdnf speaks GCancellable: https://github.com/projectatomic/rpm-ostree/issues/897 */
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return FALSE;
gboolean did_update = FALSE;
if (!dnf_repo_check(repo,
dnf_context_get_cache_age (self->hifctx),
@ -975,6 +979,9 @@ rpmostree_context_download_metadata (RpmOstreeContext *self,
repo_ts_str);
}
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return FALSE;
/* The _setup_sack function among other things imports the metadata into libsolv */
{ g_autoptr(DnfState) hifstate = dnf_state_new ();
guint progress_sigid = g_signal_connect (hifstate, "percentage-changed",