[gnome-software/290-installing-an-app-its-add-ons-at-the-same-time-doesn-t-update-the-gui-properly] packagekit: Reset addons' state after application install/remove



commit 03a6129634320c4cd32c02c8e4b955db7768f2aa
Author: Milan Crha <mcrha redhat com>
Date:   Thu May 6 18:51:22 2021 +0200

    packagekit: Reset addons' state after application install/remove
    
    Thus the state is refined the same way it is refined for the main application.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/290

 plugins/packagekit/gs-plugin-packagekit.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index e302945f7..4ae83a8f9 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -414,11 +414,23 @@ gs_plugin_app_install (GsPlugin *plugin,
                                                         error);
                g_mutex_unlock (&priv->task_mutex);
                if (!gs_plugin_packagekit_results_valid (results, error)) {
+                       for (i = 0; i < gs_app_list_length (addons); i++) {
+                               GsApp *addon = gs_app_list_index (addons, i);
+                               if (gs_app_get_state (addon) == GS_APP_STATE_INSTALLING)
+                                       gs_app_set_state_recover (addon);
+                       }
                        gs_app_set_state_recover (app);
                        return FALSE;
                }
 
                /* state is known */
+               for (i = 0; i < gs_app_list_length (addons); i++) {
+                       GsApp *addon = gs_app_list_index (addons, i);
+                       if (gs_app_get_state (addon) == GS_APP_STATE_INSTALLING) {
+                               gs_app_set_state (addon, GS_APP_STATE_INSTALLED);
+                               gs_app_clear_source_ids (addon);
+                       }
+               }
                gs_app_set_state (app, GS_APP_STATE_INSTALLED);
 
                break;
@@ -581,8 +593,10 @@ gs_plugin_app_remove (GsPlugin *plugin,
        addons = gs_app_get_addons (app);
        for (i = 0; i < gs_app_list_length (addons); i++) {
                GsApp *addon = gs_app_list_index (addons, i);
-               if (gs_app_get_state (addon) == GS_APP_STATE_INSTALLED)
+               if (gs_app_get_state (addon) == GS_APP_STATE_INSTALLED) {
                        gs_app_set_state (addon, GS_APP_STATE_UNKNOWN);
+                       gs_app_clear_source_ids (addon);
+               }
        }
 
        /* state is not known: we don't know if we can re-install this app */


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