[gnome-software/wip/hughsie/match-refine-unique-id: 2/2] Match the exact ID when refining a wildcard



commit 62322c1a58cbd609631413c4673b91e6362ae21b
Author: Richard Hughes <richard hughsie com>
Date:   Wed Oct 2 15:44:40 2019 +0100

    Match the exact ID when refining a wildcard
    
    If we specify the unique ID (for instance from a GNOME Shell search result)
    then match the *exact* GsApp rather than just returning the first one that
    only matches the GsApp ID.
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-software/issues/769

 lib/gs-plugin-loader.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 9460a803..02099fd3 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -3644,11 +3644,21 @@ gs_plugin_loader_app_create (GsPluginLoader *plugin_loader, const gchar *unique_
                return NULL;
        }
 
+       /* return the matching GsApp */
+       for (guint i = 0; i < gs_app_list_length (list); i++) {
+               GsApp *app_tmp = gs_app_list_index (list, i);
+               if (g_strcmp0 (unique_id, gs_app_get_unique_id (app_tmp)) == 0)
+                       return g_object_ref (app_tmp);
+       }
+
        /* return the first returned app that's not a wildcard */
        for (guint i = 0; i < gs_app_list_length (list); i++) {
                GsApp *app_tmp = gs_app_list_index (list, i);
-               if (!gs_app_has_quirk (app_tmp, GS_APP_QUIRK_IS_WILDCARD))
+               if (!gs_app_has_quirk (app_tmp, GS_APP_QUIRK_IS_WILDCARD)) {
+                       g_debug ("returning imperfect match: %s != %s",
+                                unique_id, gs_app_get_unique_id (app_tmp));
                        return g_object_ref (app_tmp);
+               }
        }
 
        /* does not exist */


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