[gnome-software] Correctly apply AppStream merge applications



commit 32ff604c5e8fcab858e5b5a4b01785f92c822b86
Author: Richard Hughes <richard hughsie com>
Date:   Tue May 16 13:31:32 2017 +0100

    Correctly apply AppStream merge applications
    
    We need to do this manually as some plugins (e.g. flatpak) do not share an
    AsStore and thus do not get the properties on the 'full' app subsumed correctly.

 meson.build                        |    2 +-
 plugins/core/gs-plugin-appstream.c |   16 ++++++++++++----
 2 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/meson.build b/meson.build
index ec70153..d2fff09 100644
--- a/meson.build
+++ b/meson.build
@@ -89,7 +89,7 @@ add_global_link_arguments(
   language: 'c'
 )
 
-appstream_glib = dependency('appstream-glib', version : '>= 0.6.13')
+appstream_glib = dependency('appstream-glib', version : '>= 0.7.0')
 gdk_pixbuf = dependency('gdk-pixbuf-2.0', version : '>= 2.31.5')
 gio_unix = dependency('gio-unix-2.0')
 gmodule = dependency('gmodule-2.0')
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index 9ce8069..8520316 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -396,17 +396,25 @@ gs_plugin_refine_from_id (GsPlugin *plugin,
        item = as_store_get_app_by_unique_id (priv->store, unique_id,
                                              AS_STORE_SEARCH_FLAG_USE_WILDCARDS);
        if (item == NULL) {
-               guint i;
-               GPtrArray *apps;
+               GPtrArray *apps = as_store_get_apps (priv->store);
                g_debug ("no app with ID %s found in system appstream", unique_id);
-               apps = as_store_get_apps (priv->store);
-               for (i = 0; i < apps->len; i++) {
+               for (guint i = 0; i < apps->len; i++) {
                        item = g_ptr_array_index (apps, i);
                        if (g_strcmp0 (as_app_get_id (item), gs_app_get_id (app)) != 0)
                                continue;
                        g_debug ("possible match: %s",
                                 as_app_get_unique_id (item));
                }
+
+               /* fall back to trying to get a merge app */
+               apps = as_store_get_apps_by_id_merge (priv->store, gs_app_get_id (app));
+               if (apps != NULL) {
+                       for (guint i = 0; i < apps->len; i++) {
+                               item = g_ptr_array_index (apps, i);
+                               if (!gs_appstream_refine_app (plugin, app, item, error))
+                                       return FALSE;
+                       }
+               }
                return TRUE;
        }
 


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