[gnome-software/wip/hughsie/no-wildcards-in-cache: 2/2] Never add wildcards to the plugin cache



commit 2327ee9f7dc0e5138d2a793cf1c0b0b3db37f9e8
Author: Richard Hughes <richard hughsie com>
Date:   Thu Jul 18 10:24:02 2019 +0100

    Never add wildcards to the plugin cache
    
    If the system AppStream plugin matches on an old-style merge component it
    correctly detects it as a wildcard. This result gets added to the GsAppList,
    but also gets added to the plugin cache where it causes chaos when non-wildcard
    results get dedupe'd into a wildcard entry.
    
    This fixes the searching for the application ID where pacakge results were not
    being returned and is needed if we use the plugin loader from the editor.

 lib/gs-plugin.c             | 6 ++++++
 plugins/core/gs-appstream.c | 4 ++++
 2 files changed, 10 insertions(+)
---
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index 4764ce7b..005e6cdb 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -1369,6 +1369,12 @@ gs_plugin_cache_add (GsPlugin *plugin, const gchar *key, GsApp *app)
 
        locker = g_mutex_locker_new (&priv->cache_mutex);
 
+       /* the user probably doesn't want to do this */
+       if (gs_app_has_quirk (app, GS_APP_QUIRK_IS_WILDCARD)) {
+               g_warning ("adding wildcard app %s to plugin cache",
+                          gs_app_get_unique_id (app));
+       }
+
        /* default */
        if (key == NULL)
                key = gs_app_get_unique_id (app);
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index 636b0f30..ccb88a88 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -26,6 +26,10 @@ gs_appstream_create_app (GsPlugin *plugin, XbSilo *silo, XbNode *component, GErr
                                      error))
                return NULL;
 
+       /* never add wildcard apps to the plugin cache */
+       if (gs_app_has_quirk (app_new, GS_APP_QUIRK_IS_WILDCARD))
+               return g_steal_pointer (&app_new);
+
        /* look for existing object */
        app = gs_plugin_cache_lookup (plugin, gs_app_get_unique_id (app_new));
        if (app != NULL)


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