[gnome-software: 1/2] flatpak: Allow cancelling querying update permissions




commit 9e4a7ab4064a575d70d6cf32f108abd5c5456eeb
Author: Philip Withnall <pwithnall endlessos org>
Date:   Fri Mar 19 23:15:18 2021 +0000

    flatpak: Allow cancelling querying update permissions
    
    Sometimes, calling `flatpak_installation_fetch_remote_metadata_sync()`
    can result in HTTP downloads which are not small. It’s called as part of
    searching for updates, and so a cancel button is available for it on the
    ‘Updates’ page in the UI.
    
    If the user tries to cancel searching for updates while the flatpak
    plugin is in a call to `gs_flatpak_set_update_permissions()`, nothing
    will happen and the UI will continue to show that updates are being
    searched for.
    
    Fix that by passing a `GCancellable` in, so that the permissions updates
    can be cancelled promptly.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 plugins/flatpak/gs-flatpak.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 981030861..1dd43adec 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -255,7 +255,10 @@ perms_from_metadata (GKeyFile *keyfile)
 }
 
 static void
-gs_flatpak_set_update_permissions (GsFlatpak *self, GsApp *app, FlatpakInstalledRef *xref)
+gs_flatpak_set_update_permissions (GsFlatpak           *self,
+                                   GsApp               *app,
+                                   FlatpakInstalledRef *xref,
+                                   GCancellable        *cancellable)
 {
        g_autoptr(GBytes) old_bytes = NULL;
        g_autoptr(GKeyFile) old_keyfile = NULL;
@@ -274,7 +277,7 @@ gs_flatpak_set_update_permissions (GsFlatpak *self, GsApp *app, FlatpakInstalled
        bytes = flatpak_installation_fetch_remote_metadata_sync (self->installation,
                                                                 gs_app_get_origin (app),
                                                                 FLATPAK_REF (xref),
-                                                                NULL,
+                                                                cancellable,
                                                                 &error_local);
        if (bytes == NULL) {
                g_debug ("Failed to get metadata for remote ‘%s’: %s",
@@ -1654,7 +1657,7 @@ gs_flatpak_add_updates (GsFlatpak *self, GsAppList *list,
                                }
                        }
                }
-               gs_flatpak_set_update_permissions (self, main_app, xref);
+               gs_flatpak_set_update_permissions (self, main_app, xref, cancellable);
                gs_app_list_add (list, main_app);
        }
 


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