[gnome-software: 3/4] Handle G_IO_ERROR_CANCELLED just like GS_PLUGIN_ERROR_CANCELLED




commit d971796481888b54b6f64385d9617f8993817bf1
Author: Philip Withnall <pwithnall endlessos org>
Date:   Thu Mar 3 16:18:52 2022 +0000

    Handle G_IO_ERROR_CANCELLED just like GS_PLUGIN_ERROR_CANCELLED
    
    Eventually I would like to remove `GS_PLUGIN_ERROR_CANCELLED`, as it’s
    unhelpful to duplicate a built-in error code from GIO which is
    universally used to represent cancellation in *all* the libraries
    gnome-software uses.
    
    However, untangling error handling without introducing bugs is not
    possible in the amount of time before the release, so this is a
    transition step. This is because I can’t be sure there aren’t other bits
    of gnome-software which implicitly assume an error is in the
    `GS_PLUGIN_ERROR` domain.
    
    On the assumption that some bits of gnome-software will return
    `G_IO_ERROR_CANCELLED`, and some will return
    `GS_PLUGIN_ERROR_CANCELLED`, handle both equally in all places where
    that error code is checked for.
    
    When `GS_PLUGIN_ERROR_CANCELLED` is removed, these checks can all be
    collapsed down to a simple check against `G_IO_ERROR_CANCELLED`.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 lib/gs-plugin-loader.c   |  3 ++-
 src/gs-category-page.c   |  6 ++++--
 src/gs-dbus-helper.c     |  3 ++-
 src/gs-details-page.c    |  3 ++-
 src/gs-extras-page.c     |  9 ++++++---
 src/gs-installed-page.c  |  3 ++-
 src/gs-moderate-page.c   |  6 ++++--
 src/gs-overview-page.c   | 15 ++++++++++-----
 src/gs-page.c            |  5 ++---
 src/gs-repos-dialog.c    |  8 ++++----
 src/gs-search-page.c     |  3 ++-
 src/gs-shell.c           | 27 ++++++++++++++++++---------
 src/gs-update-dialog.c   |  1 +
 src/gs-update-monitor.c  | 21 ++++++++++++++-------
 src/gs-updates-page.c    | 20 ++++++++++++--------
 src/gs-updates-section.c |  3 ++-
 16 files changed, 87 insertions(+), 49 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index be584aec5..2b414f1c1 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -763,7 +763,8 @@ gs_plugin_loader_call_vfunc (GsPluginLoaderHelper *helper,
                /* we returned cancelled, but this was because of a timeout,
                 * so re-create error, throwing the plugin under the bus */
                if (helper->timeout_triggered &&
-                   g_error_matches (error_local, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) {
+                   (g_error_matches (error_local, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                    g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_CANCELLED))) {
                        g_debug ("converting cancelled to timeout");
                        g_clear_error (&error_local);
                        g_set_error (&error_local,
diff --git a/src/gs-category-page.c b/src/gs-category-page.c
index 5c420c500..93a45486d 100644
--- a/src/gs-category-page.c
+++ b/src/gs-category-page.c
@@ -136,7 +136,8 @@ gs_category_page_get_featured_apps_cb (GObject *source_object,
                                                    res,
                                                    &local_error);
        if (list == NULL) {
-               if (!g_error_matches (local_error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (local_error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_warning ("failed to get featured apps for category apps: %s", local_error->message);
                data->get_featured_apps_finished = TRUE;
                load_category_finish (data);
@@ -170,7 +171,8 @@ gs_category_page_get_apps_cb (GObject *source_object,
                                                    res,
                                                    &local_error);
        if (list == NULL) {
-               if (!g_error_matches (local_error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (local_error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_warning ("failed to get apps for category apps: %s", local_error->message);
                data->get_main_apps_finished = TRUE;
                load_category_finish (data);
diff --git a/src/gs-dbus-helper.c b/src/gs-dbus-helper.c
index 47eab521c..db4dcf42f 100644
--- a/src/gs-dbus-helper.c
+++ b/src/gs-dbus-helper.c
@@ -724,7 +724,8 @@ bus_gotten_cb (GObject      *source_object,
 
        connection = g_bus_get_finish (res, &error);
        if (connection == NULL) {
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_warning ("Could not get session bus: %s", error->message);
                return;
        }
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index b9f5c1e03..4216981ab 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -615,7 +615,8 @@ gs_details_page_get_alternates_cb (GObject *source_object,
                                                    res,
                                                    &error);
        if (list == NULL) {
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_warning ("failed to get alternates: %s", error->message);
                gtk_widget_hide (self->origin_box);
                return;
diff --git a/src/gs-extras-page.c b/src/gs-extras-page.c
index e3916e430..736d48f7f 100644
--- a/src/gs-extras-page.c
+++ b/src/gs-extras-page.c
@@ -566,7 +566,8 @@ search_files_cb (GObject *source_object,
        list = gs_plugin_loader_job_process_finish (plugin_loader, res, &error);
        if (list == NULL) {
                g_autofree gchar *str = NULL;
-               if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) {
+               if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                   g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                        g_debug ("extras: search files cancelled");
                        return;
                }
@@ -614,7 +615,8 @@ file_to_app_cb (GObject *source_object,
 
        list = gs_plugin_loader_job_process_finish (plugin_loader, res, &error);
        if (list == NULL) {
-               if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) {
+               if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                   g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                        g_debug ("extras: search what provides cancelled");
                        return;
                }
@@ -661,7 +663,8 @@ get_search_what_provides_cb (GObject *source_object,
        list = gs_plugin_loader_job_process_finish (plugin_loader, res, &error);
        if (list == NULL) {
                g_autofree gchar *str = NULL;
-               if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) {
+               if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                   g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                        g_debug ("extras: search what provides cancelled");
                        return;
                }
diff --git a/src/gs-installed-page.c b/src/gs-installed-page.c
index 3817ab01f..081fa65cc 100644
--- a/src/gs-installed-page.c
+++ b/src/gs-installed-page.c
@@ -391,7 +391,8 @@ gs_installed_page_get_installed_cb (GObject *source_object,
                                                    res,
                                                    &error);
        if (list == NULL) {
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_warning ("failed to get installed apps: %s", error->message);
                goto out;
        }
diff --git a/src/gs-moderate-page.c b/src/gs-moderate-page.c
index c26d0bbdc..0deefcfda 100644
--- a/src/gs-moderate-page.c
+++ b/src/gs-moderate-page.c
@@ -205,7 +205,8 @@ gs_moderate_page_refine_unvoted_reviews_cb (GObject      *source_object,
                                                            res,
                                                            &error);
        if (list == NULL) {
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_warning ("failed to get moderate apps: %s", error->message);
                return;
        }
@@ -236,7 +237,8 @@ gs_moderate_page_load (GsModeratePage *self)
        /* get unvoted reviews as apps */
        if (!gs_odrs_provider_add_unvoted_reviews (self->odrs_provider, list,
                                                   self->cancellable, &local_error)) {
-               if (!g_error_matches (local_error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (local_error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_warning ("failed to get moderate apps: %s", local_error->message);
                return;
        }
diff --git a/src/gs-overview-page.c b/src/gs-overview-page.c
index 50e2e2cfb..c640172b0 100644
--- a/src/gs-overview-page.c
+++ b/src/gs-overview-page.c
@@ -135,7 +135,8 @@ gs_overview_page_get_popular_cb (GObject *source_object,
        /* get popular apps */
        list = gs_plugin_loader_job_process_finish (plugin_loader, res, &error);
        if (list == NULL) {
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_warning ("failed to get popular apps: %s", error->message);
                goto out;
        }
@@ -184,7 +185,8 @@ gs_overview_page_get_recent_cb (GObject *source_object, GAsyncResult *res, gpoin
        /* get recent apps */
        list = gs_plugin_loader_job_process_finish (plugin_loader, res, &error);
        if (list == NULL) {
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_warning ("failed to get recent apps: %s", error->message);
                goto out;
        }
@@ -253,7 +255,8 @@ gs_overview_page_get_featured_cb (GObject *source_object,
        g_autoptr(GsAppList) list = NULL;
 
        list = gs_plugin_loader_job_process_finish (plugin_loader, res, &error);
-       if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+       if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+           g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                goto out;
 
        if (self->featured_overwritten) {
@@ -317,7 +320,8 @@ gs_overview_page_get_categories_cb (GObject *source_object,
 
        list = gs_plugin_loader_job_get_categories_finish (plugin_loader, res, &error);
        if (list == NULL) {
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_warning ("failed to get categories: %s", error->message);
                goto out;
        }
@@ -580,7 +584,8 @@ gs_overview_page_refresh_cb (GsPluginLoader *plugin_loader,
 
        success = gs_plugin_loader_job_action_finish (plugin_loader, result, &error);
        if (!success &&
-           !g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+           !g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+           !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                g_warning ("failed to refresh: %s", error->message);
 
        if (success)
diff --git a/src/gs-page.c b/src/gs-page.c
index 25b4a4160..4ba414b3d 100644
--- a/src/gs-page.c
+++ b/src/gs-page.c
@@ -199,9 +199,8 @@ gs_page_app_removed_cb (GObject *source,
        ret = gs_plugin_loader_job_action_finish (plugin_loader,
                                                   res,
                                                   &error);
-       if (g_error_matches (error,
-                            GS_PLUGIN_ERROR,
-                            GS_PLUGIN_ERROR_CANCELLED)) {
+       if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+           g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                g_debug ("%s", error->message);
                return;
        }
diff --git a/src/gs-repos-dialog.c b/src/gs-repos-dialog.c
index 17d999ffd..e12a4ac5e 100644
--- a/src/gs-repos-dialog.c
+++ b/src/gs-repos-dialog.c
@@ -76,7 +76,8 @@ repo_enabled_cb (GObject *source,
                gs_repo_row_unmark_busy (row);
 
        if (!gs_plugin_loader_job_action_finish (plugin_loader, res, &error)) {
-               if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) {
+               if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                   g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                        g_debug ("repo %s cancelled", action_str);
                        return;
                }
@@ -438,9 +439,8 @@ get_sources_cb (GsPluginLoader *plugin_loader,
        /* get the results */
        list = gs_plugin_loader_job_process_finish (plugin_loader, res, &error);
        if (list == NULL) {
-               if (g_error_matches (error,
-                                    GS_PLUGIN_ERROR,
-                                    GS_PLUGIN_ERROR_CANCELLED)) {
+               if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                   g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                        g_debug ("get sources cancelled");
                        return;
                } else {
diff --git a/src/gs-search-page.c b/src/gs-search-page.c
index d58ef9d25..95d5cffe7 100644
--- a/src/gs-search-page.c
+++ b/src/gs-search-page.c
@@ -115,7 +115,8 @@ gs_search_page_get_search_cb (GObject *source_object,
 
        list = gs_plugin_loader_job_process_finish (plugin_loader, res, &error);
        if (list == NULL) {
-               if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) {
+               if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                   g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                        g_debug ("search cancelled");
                        return;
                }
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 967124ce3..81c3f87f2 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -1317,7 +1317,8 @@ gs_shell_show_event_refresh (GsShell *shell, GsPluginEvent *event)
                /* TRANSLATORS: failure text for the in-app notification */
                g_string_append (str, _("Unable to download updates: you do not have"
                                        " permission to install software"));
-       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) {
+       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                  g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                /* Do nothing. */
        } else {
                if (action == GS_PLUGIN_ACTION_DOWNLOAD) {
@@ -1440,7 +1441,8 @@ gs_shell_show_event_install (GsShell *shell, GsPluginEvent *event)
                g_string_append_printf (str, _("Unable to install %s: "
                                               "The battery level is too low"),
                                        str_app);
-       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) {
+       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                  g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                /* Do nothing. */
        } else {
                /* TRANSLATORS: failure text for the in-app notification,
@@ -1600,7 +1602,8 @@ gs_shell_show_event_update (GsShell *shell, GsPluginEvent *event)
                        g_string_append_printf (str, _("Unable to install updates: "
                                                       "The battery level is too low"));
                }
-       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) {
+       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                  g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                /* Do nothing. */
        } else {
                if (app != NULL) {
@@ -1707,7 +1710,8 @@ gs_shell_show_event_upgrade (GsShell *shell, GsPluginEvent *event)
                g_string_append_printf (str, _("Unable to upgrade to %s: "
                                               "The battery level is too low"),
                                        str_app);
-       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) {
+       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                  g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                /* Do nothing. */
        } else {
                /* TRANSLATORS: failure text for the in-app notification,
@@ -1774,7 +1778,8 @@ gs_shell_show_event_remove (GsShell *shell, GsPluginEvent *event)
                g_string_append_printf (str, _("Unable to remove %s: "
                                               "The battery level is too low"),
                                        str_app);
-       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) {
+       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                  g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                /* Do nothing. */
        } else {
                /* non-interactive generic */
@@ -1832,7 +1837,8 @@ gs_shell_show_event_launch (GsShell *shell, GsPluginEvent *event)
                g_string_append (str, _("Not enough disk space — free up some space "
                                        "and try again"));
                buttons |= GS_SHELL_EVENT_BUTTON_NO_SPACE;
-       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) {
+       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                  g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                /* Do nothing. */
        } else {
                /* non-interactive generic */
@@ -1879,7 +1885,8 @@ gs_shell_show_event_file_to_app (GsShell *shell, GsPluginEvent *event)
                g_string_append (str, _("Not enough disk space — free up some space "
                                        "and try again"));
                buttons |= GS_SHELL_EVENT_BUTTON_NO_SPACE;
-       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) {
+       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                  g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                /* Do nothing. */
        } else {
                /* non-interactive generic */
@@ -1916,7 +1923,8 @@ gs_shell_show_event_url_to_app (GsShell *shell, GsPluginEvent *event)
                g_string_append (str, _("Not enough disk space — free up some space "
                                        "and try again"));
                buttons |= GS_SHELL_EVENT_BUTTON_NO_SPACE;
-       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) {
+       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                  g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                /* Do nothing. */
        } else {
                /* non-interactive generic */
@@ -1968,7 +1976,8 @@ gs_shell_show_event_fallback (GsShell *shell, GsPluginEvent *event)
        } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_BATTERY_LEVEL_TOO_LOW)) {
                /* TRANSLATORS: not enough juice to do this safely */
                g_string_append (str, _("The battery level is too low"));
-       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) {
+       } else if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                  g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                /* Do nothing. */
        } else {
                /* non-interactive generic */
diff --git a/src/gs-update-dialog.c b/src/gs-update-dialog.c
index 70519247a..6bcbce10c 100644
--- a/src/gs-update-dialog.c
+++ b/src/gs-update-dialog.c
@@ -89,6 +89,7 @@ get_installed_updates_cb (GsPluginLoader *plugin_loader,
        /* if we're in teardown, short-circuit and return immediately without
         * dereferencing priv variables */
        if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+           g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) ||
            dialog->spinner == NULL) {
                g_debug ("get installed updates cancelled");
                return;
diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c
index dd4a30fbc..d6898e23a 100644
--- a/src/gs-update-monitor.c
+++ b/src/gs-update-monitor.c
@@ -518,7 +518,8 @@ get_updates_finished_cb (GObject *object, GAsyncResult *res, gpointer data)
        /* get result */
        apps = gs_plugin_loader_job_process_finish (GS_PLUGIN_LOADER (object), res, &error);
        if (apps == NULL) {
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_warning ("failed to get updates: %s", error->message);
                return;
        }
@@ -636,7 +637,8 @@ get_system_finished_cb (GObject *object, GAsyncResult *res, gpointer data)
        /* get result */
        app = gs_plugin_loader_get_system_app_finish (plugin_loader, res, &error);
        if (app == NULL) {
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_warning ("failed to get system: %s", error->message);
                return;
        }
@@ -676,7 +678,8 @@ get_upgrades_finished_cb (GObject *object,
        /* get result */
        apps = gs_plugin_loader_job_process_finish (GS_PLUGIN_LOADER (object), res, &error);
        if (apps == NULL) {
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) {
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                        g_warning ("failed to get upgrades: %s",
                                   error->message);
                }
@@ -798,7 +801,8 @@ refresh_cache_finished_cb (GObject *object,
        g_autoptr(GError) error = NULL;
 
        if (!gs_plugin_loader_job_action_finish (GS_PLUGIN_LOADER (object), res, &error)) {
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_warning ("failed to refresh the cache: %s", error->message);
                return;
        }
@@ -828,7 +832,8 @@ install_language_pack_cb (GObject *object, GAsyncResult *res, gpointer data)
        g_autoptr(WithAppData) with_app_data = data;
 
        if (!gs_plugin_loader_job_action_finish (GS_PLUGIN_LOADER (object), res, &error)) {
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_debug ("failed to install language pack: %s", error->message);
                return;
        } else {
@@ -847,7 +852,8 @@ get_language_pack_cb (GObject *object, GAsyncResult *res, gpointer data)
 
        app_list = gs_plugin_loader_job_process_finish (GS_PLUGIN_LOADER (object), res, &error);
        if (app_list == NULL) {
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_debug ("failed to find language pack: %s", error->message);
                return;
        }
@@ -1219,7 +1225,8 @@ gs_update_monitor_show_error (GsUpdateMonitor *monitor, GtkWindow *window)
                 * the updates were prepared */
                msg = _("The system was already up to date.");
                show_detailed_error = TRUE;
-       } else if (g_error_matches (monitor->last_offline_error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) 
{
+       } else if (g_error_matches (monitor->last_offline_error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) 
||
+                  g_error_matches (monitor->last_offline_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                /* TRANSLATORS: the user aborted the update manually */
                msg = _("The update was cancelled.");
                show_detailed_error = FALSE;
diff --git a/src/gs-updates-page.c b/src/gs-updates-page.c
index 686ec740c..b01ffbbe9 100644
--- a/src/gs-updates-page.c
+++ b/src/gs-updates-page.c
@@ -448,7 +448,8 @@ gs_updates_page_get_updates_cb (GsPluginLoader *plugin_loader,
        list = gs_plugin_loader_job_process_finish (plugin_loader, res, &error);
        if (list == NULL) {
                gs_updates_page_clear_flag (self, GS_UPDATES_PAGE_FLAG_HAS_UPDATES);
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_warning ("updates-shell: failed to get updates: %s", error->message);
                adw_status_page_set_description (ADW_STATUS_PAGE (self->updates_failed_page),
                                                 error->message);
@@ -493,7 +494,8 @@ gs_updates_page_get_upgrades_cb (GObject *source_object,
        list = gs_plugin_loader_job_process_finish (plugin_loader, res, &error);
        if (list == NULL) {
                gs_updates_page_clear_flag (self, GS_UPDATES_PAGE_FLAG_HAS_UPGRADES);
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) {
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                        g_warning ("updates-shell: failed to get upgrades: %s",
                                   error->message);
                }
@@ -555,7 +557,8 @@ gs_updates_page_refine_system_finished_cb (GObject *source_object,
 
        /* get result */
        if (!gs_plugin_loader_job_action_finish (plugin_loader, res, &error)) {
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_warning ("Failed to refine system: %s", error->message);
                return;
        }
@@ -605,7 +608,8 @@ gs_updates_page_get_system_finished_cb (GObject *source_object,
 
        app = gs_plugin_loader_get_system_app_finish (plugin_loader, res, &error);
        if (app == NULL) {
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_warning ("Failed to get system: %s", error->message);
                return;
        }
@@ -737,9 +741,8 @@ gs_updates_page_refresh_cb (GsPluginLoader *plugin_loader,
        ret = gs_plugin_loader_job_action_finish (plugin_loader, res, &error);
        if (!ret) {
                /* user cancel */
-               if (g_error_matches (error,
-                                    GS_PLUGIN_ERROR,
-                                    GS_PLUGIN_ERROR_CANCELLED)) {
+               if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                   g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
                        gs_updates_page_set_state (self, GS_UPDATES_PAGE_STATE_IDLE);
                        return;
                }
@@ -922,7 +925,8 @@ upgrade_download_finished_cb (GObject *source,
        g_autoptr(GError) error = NULL;
 
        if (!gs_plugin_loader_job_action_finish (plugin_loader, res, &error)) {
-               if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) ||
+                   g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        return;
                g_warning ("failed to upgrade-download: %s", error->message);
        }
diff --git a/src/gs-updates-section.c b/src/gs-updates-section.c
index c3a835198..1b416f772 100644
--- a/src/gs-updates-section.c
+++ b/src/gs-updates-section.c
@@ -404,7 +404,8 @@ _download_finished_cb (GObject *object, GAsyncResult *res, gpointer user_data)
        /* get result */
        list = gs_plugin_loader_job_process_finish (GS_PLUGIN_LOADER (object), res, &error);
        if (list == NULL) {
-               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
                        g_warning ("failed to download updates: %s", error->message);
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]