[gnome-software/wip/jrocha/fix-runtime-extensions-update: 2/5] flatpak: Refine extensions when getting them



commit ab694f4b952c33e0a9447aa511256985e15f73a6
Author: Joaquim Rocha <jrocha endlessm com>
Date:   Mon Nov 6 14:26:26 2017 +0100

    flatpak: Refine extensions when getting them
    
    When installing or removing an app, a list with the app's related
    extensions is gathered in order to install/remove them as well.
    The lists in this app may not have the correct state assigned when
    they're gathered though, so when installing/removing them, there will
    be a warning about an unexpected change of state.
    
    These changes refine the mentioned extensions meaning which will
    (hopefully) set up the right state and allow the further state changes
    from further operations (installation/removal).

 plugins/flatpak/gs-flatpak.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 5df5b506..2cb6b698 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -2327,10 +2327,23 @@ gs_flatpak_get_list_for_remove (GsFlatpak *self, GsApp *app,
        for (guint i = 0; i < related->len; i++) {
                FlatpakRelatedRef *xref_related = g_ptr_array_index (related, i);
                g_autoptr(GsApp) app_tmp = NULL;
+               g_autoptr(GError) error_local = NULL;
+
                if (!flatpak_related_ref_should_delete (xref_related))
                        continue;
                app_tmp = gs_flatpak_create_app (self, FLATPAK_REF (xref_related));
                gs_app_set_origin (app_tmp, gs_app_get_origin (app));
+               if (!gs_plugin_refine_item_state (self, app_tmp, cancellable, &error_local)) {
+                       if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+                               g_propagate_error (error, g_steal_pointer (&error_local));
+                               return NULL;
+                       }
+                       g_warning ("Failed to refine %s when getting the list of apps to "
+                                  "remove: %s; not adding the app...",
+                                  gs_app_get_unique_id (app_tmp),
+                                  error_local->message);
+                       continue;
+               }
                gs_app_list_add (list, app_tmp);
        }
 
@@ -2509,6 +2522,7 @@ gs_flatpak_get_list_for_install (GsFlatpak *self, GsApp *app,
                FlatpakRelatedRef *xref_related = g_ptr_array_index (related, i);
                g_autofree gchar *ref_display = NULL;
                g_autoptr(GsApp) app_tmp = NULL;
+               g_autoptr(GError) error_local = NULL;
 
                /* not included */
                if (!gs_flatpak_related_should_download (self, app, xref_related))
@@ -2522,6 +2536,19 @@ gs_flatpak_get_list_for_install (GsFlatpak *self, GsApp *app,
                } else {
                        gs_app_set_origin (app_tmp, gs_app_get_origin (app));
                        g_debug ("adding related %s for install", ref_display);
+
+                       if (!gs_plugin_refine_item_state (self, app_tmp, cancellable, &error_local)) {
+                               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+                                       g_propagate_error (error, g_steal_pointer (&error_local));
+                                       return NULL;
+                               }
+                               g_warning ("Failed to refine %s when getting the list of apps to "
+                                          "install: %s; not adding the app...",
+                                          gs_app_get_unique_id (app_tmp),
+                                          error_local->message);
+                               continue;
+                       }
+
                        gs_app_list_add (list, app_tmp);
                }
        }


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