[gnome-software/wip/jrocha/fix_popular_overrides: 17/20] Always create an app if the cached one matches any prefix in gs-appstream



commit a5ccf50d99e4709572d733df539d3d881ba3387a
Author: Joaquim Rocha <jrocha endlessm com>
Date:   Fri Mar 31 21:17:15 2017 +0200

    Always create an app if the cached one matches any prefix in gs-appstream
    
    When creating an app, if there's a matching cached one but it has the
    "match any prefix" quirk, then we should proceed with creating a new app
    because the cached one, due to that quirk, will behave differently than
    our newly created one: e.g. it'll use refine_wildcard, it won't be able
    to get a management plugin, etc.
    
    This prevents problems associated with the behaviors mentioned above:
    e.g. if there's an app in the global cache matching any prefix, and then
    AppStream tries to create one from the AppStream data, it would reuse
    the cached one instead; then it would be refined but would never get an
    icon because the icons plugin does not implement refine_wildcard.

 plugins/core/gs-appstream.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index 7698bad..33df85b 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -32,6 +32,20 @@ gs_appstream_create_app (GsPlugin *plugin, AsApp *item, GError **error)
 {
        const gchar *unique_id = as_app_get_unique_id (item);
        GsApp *app = gs_plugin_cache_lookup (plugin, unique_id);
+
+       /* if the app we found has the "match-any-prefix" quirk and our item does
+        * not, then we create a new one because ours will be "complete", and
+        * using the mentioned quirk will lead to a different behavior (e.g. it'll
+        * be refined using refine_wildcard, it won't allow a management plugin to
+        * be set, etc.)  */
+       if (app != NULL && gs_app_has_quirk (app, AS_APP_QUIRK_MATCH_ANY_PREFIX) &&
+           !as_app_has_quirk (item, AS_APP_QUIRK_MATCH_ANY_PREFIX)) {
+               g_debug ("Looking for %s, got %s but has 'match-any-prefix' quirk "
+                        "so we create a new one instead.",
+                        unique_id, gs_app_get_unique_id (app));
+               g_clear_object (&app);
+       }
+
        if (app == NULL) {
                app = gs_app_new_from_unique_id (unique_id);
                gs_app_set_metadata (app, "GnomeSoftware::Creator",


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