[gnome-software/1248-flatpaks-should-be-updated-daily] gs-update-monitor: Automatically install application updates



commit 916646f00ed1fbe5e79c4b8d6c479cf318c6e319
Author: Milan Crha <mcrha redhat com>
Date:   Tue May 11 11:13:52 2021 +0200

    gs-update-monitor: Automatically install application updates
    
    The application updates, so called online updates, should be installed immediately
    when found, when the user has enabled automatic updates.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1248

 src/gs-update-monitor.c | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)
---
diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c
index f22b5eb28..5bbc1f60f 100644
--- a/src/gs-update-monitor.c
+++ b/src/gs-update-monitor.c
@@ -536,7 +536,42 @@ get_updates_finished_cb (GObject *object, GAsyncResult *res, gpointer data)
                                                    download_finished_cb,
                                                    monitor);
        } else {
-               notify_about_pending_updates (monitor, apps);
+               g_autoptr(GsAppList) update_online = NULL;
+               g_autoptr(GsAppList) update_offline = NULL;
+
+               update_online = gs_app_list_new ();
+               update_offline = gs_app_list_new ();
+               for (guint i = 0; i < gs_app_list_length (apps); i++) {
+                       GsApp *app = gs_app_list_index (apps, i);
+                       if (_should_auto_update (app)) {
+                               g_debug ("download for auto-update %s", gs_app_get_unique_id (app));
+                               gs_app_list_add (update_online, app);
+                       } else {
+                               gs_app_list_add (update_offline, app);
+                       }
+               }
+
+               g_debug ("Received %u apps to update, %u are online and %u offline updates",
+                       gs_app_list_length (apps),
+                       gs_app_list_length (update_online),
+                       gs_app_list_length (update_offline));
+
+               if (gs_app_list_length (update_online) > 0) {
+                       g_autoptr(GsPluginJob) plugin_job = NULL;
+
+                       plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_DOWNLOAD,
+                                                        "list", update_online,
+                                                        NULL);
+                       g_debug ("Getting %u online updates", gs_app_list_length (update_online));
+                       gs_plugin_loader_job_process_async (monitor->plugin_loader,
+                                                           plugin_job,
+                                                           monitor->cancellable,
+                                                           download_finished_cb,
+                                                           monitor);
+               }
+
+               if (gs_app_list_length (update_offline) > 0)
+                       notify_about_pending_updates (monitor, update_offline);
 
                reset_update_notification_timestamp (monitor);
        }


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