[gnome-software/wip/install-queue: 2/2] gs-plugin-loader: Add not removed from the install-queue file




commit 88f6d89b71366ace9d2b904b59c4f9da252cec34
Author: Milan Crha <mcrha redhat com>
Date:   Wed Aug 10 14:24:51 2022 +0200

    gs-plugin-loader: Add not removed from the install-queue file
    
    The plugin loader has two places, which maintain the pending queue,
    but they do not agree on the update of the install-queue file. Let
    the functions be re-used, to avoid the problem.

 lib/gs-plugin-loader.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 073008d55..36c20b53d 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -88,6 +88,7 @@ struct _GsPluginLoader
 
 static void gs_plugin_loader_monitor_network (GsPluginLoader *plugin_loader);
 static void add_app_to_install_queue (GsPluginLoader *plugin_loader, GsApp *app);
+static gboolean remove_app_from_install_queue (GsPluginLoader *plugin_loader, GsApp *app);
 static void gs_plugin_loader_process_in_thread_pool_cb (gpointer data, gpointer user_data);
 static void gs_plugin_loader_status_changed_cb (GsPlugin       *plugin,
                                                 GsApp          *app,
@@ -1078,15 +1079,11 @@ gs_plugin_loader_pending_apps_add (GsPluginLoader *plugin_loader,
                                   GsPluginLoaderHelper *helper)
 {
        GsAppList *list = gs_plugin_job_get_list (helper->plugin_job);
-       g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&plugin_loader->pending_apps_mutex);
-
-       if (plugin_loader->pending_apps == NULL)
-               plugin_loader->pending_apps = gs_app_list_new ();
 
        g_assert (gs_app_list_length (list) > 0);
        for (guint i = 0; i < gs_app_list_length (list); i++) {
                GsApp *app = gs_app_list_index (list, i);
-               gs_app_list_add (plugin_loader->pending_apps, app);
+               add_app_to_install_queue (plugin_loader, app);
                /* make sure the progress is properly initialized */
                gs_app_set_progress (app, GS_APP_PROGRESS_UNKNOWN);
        }
@@ -1098,13 +1095,11 @@ gs_plugin_loader_pending_apps_remove (GsPluginLoader *plugin_loader,
                                      GsPluginLoaderHelper *helper)
 {
        GsAppList *list = gs_plugin_job_get_list (helper->plugin_job);
-       g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&plugin_loader->pending_apps_mutex);
 
        g_assert (gs_app_list_length (list) > 0);
        for (guint i = 0; i < gs_app_list_length (list); i++) {
                GsApp *app = gs_app_list_index (list, i);
-               if (plugin_loader->pending_apps != NULL)
-                       gs_app_list_remove (plugin_loader->pending_apps, app);
+               remove_app_from_install_queue (plugin_loader, app);
 
                /* check the app is not still in an action helper */
                switch (gs_app_get_state (app)) {
@@ -1272,6 +1267,9 @@ remove_app_from_install_queue (GsPluginLoader *plugin_loader, GsApp *app)
        g_mutex_unlock (&plugin_loader->pending_apps_mutex);
 
        if (ret) {
+               if (gs_app_get_state (app) == GS_APP_STATE_QUEUED_FOR_INSTALL)
+                       gs_app_set_state (app, GS_APP_STATE_UNKNOWN);
+
                id = g_idle_add (emit_pending_apps_idle, g_object_ref (plugin_loader));
                g_source_set_name_by_id (id, "[gnome-software] emit_pending_apps_idle");
                save_install_queue (plugin_loader);


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