[gnome-software/1271-40-2-flatpaks-not-updated-despite-notification: 24/24] gs-update-monitor: Request to receive action error




commit e7e6b0d231e8f5f10a068ae2c03322b8dfdfad35
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jun 29 14:32:53 2021 +0200

    gs-update-monitor: Request to receive action error
    
    This is needed to know whether the action really succeeded or not,
    to avoid false notifications about updated applications in the background.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1271

 lib/gs-plugin-loader.c  |  3 ++-
 src/gs-update-monitor.c | 25 +++++++++++++++++++------
 2 files changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 505543a64..a824746e5 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -347,7 +347,8 @@ gs_plugin_loader_add_event (GsPluginLoader *plugin_loader, GsPluginEvent *event)
  * to a concrete application, in which case any cached application
  * overrides the passed in @app.
  *
- * The 'cancelled' errors are automatically ignored.
+ * The %GS_PLUGIN_ERROR_CANCELLED and %G_IO_ERROR_CANCELLED errors
+ * are automatically ignored.
  *
  * Since: 41
  **/
diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c
index cae30139a..21ba4088e 100644
--- a/src/gs-update-monitor.c
+++ b/src/gs-update-monitor.c
@@ -385,14 +385,19 @@ static void
 update_finished_cb (GObject *object, GAsyncResult *res, gpointer data)
 {
        GsUpdateMonitor *monitor = GS_UPDATE_MONITOR (data);
+       GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (object);
        g_autoptr(GError) error = NULL;
        g_autoptr(GsAppList) list = NULL;
 
        /* get result */
-       list = gs_plugin_loader_job_process_finish (GS_PLUGIN_LOADER (object), res, &error);
+       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))
-                       g_warning ("failed update application: %s", error->message);
+               gs_plugin_loader_claim_error (plugin_loader,
+                                             NULL,
+                                             GS_PLUGIN_ACTION_UPDATE,
+                                             NULL,
+                                             TRUE,
+                                             error);
                return;
        }
 
@@ -424,16 +429,21 @@ static void
 download_finished_cb (GObject *object, GAsyncResult *res, gpointer data)
 {
        GsUpdateMonitor *monitor = GS_UPDATE_MONITOR (data);
+       GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (object);
        g_autoptr(GError) error = NULL;
        g_autoptr(GsAppList) list = NULL;
        g_autoptr(GsAppList) update_online = NULL;
        g_autoptr(GsAppList) update_offline = NULL;
 
        /* get result */
-       list = gs_plugin_loader_job_process_finish (GS_PLUGIN_LOADER (object), res, &error);
+       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))
-                       g_warning ("failed to get updates: %s", error->message);
+               gs_plugin_loader_claim_error (plugin_loader,
+                                             NULL,
+                                             GS_PLUGIN_ACTION_DOWNLOAD,
+                                             NULL,
+                                             TRUE,
+                                             error);
                return;
        }
 
@@ -454,6 +464,7 @@ download_finished_cb (GObject *object, GAsyncResult *res, gpointer data)
                g_autoptr(GsPluginJob) plugin_job = NULL;
                plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_UPDATE,
                                                 "list", update_online,
+                                                "propagate-error", TRUE,
                                                 NULL);
                gs_plugin_loader_job_process_async (monitor->plugin_loader,
                                                    plugin_job,
@@ -524,6 +535,7 @@ get_updates_finished_cb (GObject *object, GAsyncResult *res, gpointer data)
                 * preferences */
                plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_DOWNLOAD,
                                                 "list", apps,
+                                                "propagate-error", TRUE,
                                                 NULL);
                g_debug ("Getting updates");
                gs_plugin_loader_job_process_async (monitor->plugin_loader,
@@ -559,6 +571,7 @@ get_updates_finished_cb (GObject *object, GAsyncResult *res, gpointer data)
 
                        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_DOWNLOAD,
                                                         "list", update_online,
+                                                        "propagate-error", TRUE,
                                                         NULL);
                        g_debug ("Getting %u online updates", gs_app_list_length (update_online));
                        gs_plugin_loader_job_process_async (monitor->plugin_loader,


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