[gnome-software/wip/kalev/flatpak-noenumerate-rewrite] flatpak: Rewrite dodgy noenumarate=true filtering code



commit 6be69e4e777bd6754bec0ba506d41695305a6d27
Author: Kalev Lember <klember redhat com>
Date:   Mon Nov 19 19:04:33 2018 +0100

    flatpak: Rewrite dodgy noenumarate=true filtering code
    
    Use new flatpak API to figure out what app to use from noenumerate=true
    remotes.
    
    This fixes the appdata info to correctly show up for various flatpakref
    files where the previous heuristics failed.
    
    Fixes: https://gitlab.gnome.org/GNOME/gnome-software/issues/195

 plugins/flatpak/gs-flatpak.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index e85a8566..6e7843db 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -254,7 +254,9 @@ gs_flatpak_add_apps_from_xremote (GsFlatpak *self,
        g_autofree gchar *appstream_dir_fn = NULL;
        g_autofree gchar *appstream_fn = NULL;
        g_autofree gchar *default_branch = NULL;
-       g_autofree gchar *only_app_id = NULL;
+#if FLATPAK_CHECK_VERSION(1,1,1)
+       g_autofree gchar *main_ref = NULL;
+#endif
        g_autoptr(AsStore) store = NULL;
        g_autoptr(GFile) appstream_dir = NULL;
        g_autoptr(GFile) file = NULL;
@@ -304,13 +306,10 @@ gs_flatpak_add_apps_from_xremote (GsFlatpak *self,
                as_app_set_origin (app, flatpak_remote_get_name (xremote));
        }
 
-       /* only add the specific app for noenumerate=true */
-       if (flatpak_remote_get_noenumerate (xremote)) {
-               g_autofree gchar *tmp = NULL;
-               tmp = g_strdup (flatpak_remote_get_name (xremote));
-               g_strdelimit (tmp, "-", '\0');
-               only_app_id = g_strdup_printf ("%s.desktop", tmp);
-       }
+#if FLATPAK_CHECK_VERSION(1,1,1)
+       /* only add the specific ref for noenumerate=true */
+       main_ref = flatpak_remote_get_main_ref (xremote);
+#endif
 
        /* do we want to filter to the default branch */
        settings = g_settings_new ("org.gnome.software");
@@ -322,12 +321,18 @@ gs_flatpak_add_apps_from_xremote (GsFlatpak *self,
        for (guint i = 0; i < apps->len; i++) {
                AsApp *app = g_ptr_array_index (apps, i);
 
-               /* filter to app */
-               if (only_app_id != NULL &&
-                   g_strcmp0 (as_app_get_id (app), only_app_id) != 0) {
-                       as_app_set_kind (app, AS_APP_KIND_UNKNOWN);
-                       continue;
+#if FLATPAK_CHECK_VERSION(1,1,1)
+               /* only add the specific ref for noenumerate=true */
+               if (flatpak_remote_get_noenumerate (xremote)) {
+                       AsBundle *bundle = as_app_get_bundle_default (app);
+                       if (bundle == NULL || main_ref == NULL)
+                               continue;
+                       if (g_strcmp0 (as_bundle_get_id (bundle), main_ref) != 0) {
+                               as_app_set_kind (app, AS_APP_KIND_UNKNOWN);
+                               continue;
+                       }
                }
+#endif
 
                /* filter by branch */
                if (default_branch != NULL &&


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