From c0ef5eec4f02c3e27417a2e1715e4d0c79068901 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 28 Sep 2017 13:31:41 -0400 Subject: [PATCH] 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 --- src/libpriv/rpmostree-core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libpriv/rpmostree-core.c b/src/libpriv/rpmostree-core.c index d5fe8e3d..93d5030b 100644 --- a/src/libpriv/rpmostree-core.c +++ b/src/libpriv/rpmostree-core.c @@ -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",