[gnome-software/1237-fedora-rpm-repo-hidden-by-rpm-fusion-repo] gs-plugin-appstream: Search with appstream origin, if available



commit 9adfe785f8fdae6e4e32fd5d56b5b82322e2d780
Author: Milan Crha <mcrha redhat com>
Date:   Wed May 5 18:42:52 2021 +0200

    gs-plugin-appstream: Search with appstream origin, if available
    
    When the app has set an appstream origin, then search with it, to better
    match the application in case it's provided by multiple repositories.

 plugins/core/gs-plugin-appstream.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index 953b65290..6f0c97ea1 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -798,7 +798,7 @@ gs_plugin_refine_from_id (GsPlugin *plugin,
                          GError **error)
 {
        GsPluginData *priv = gs_plugin_get_data (plugin);
-       const gchar *id;
+       const gchar *id, *origin;
        g_autoptr(GError) error_local = NULL;
        g_autoptr(GRWLockReaderLocker) locker = NULL;
        g_autoptr(GString) xpath = g_string_new (NULL);
@@ -811,9 +811,16 @@ gs_plugin_refine_from_id (GsPlugin *plugin,
 
        locker = g_rw_lock_reader_locker_new (&priv->silo_lock);
 
+       origin = gs_app_get_origin_appstream (app);
+
        /* look in AppStream then fall back to AppData */
-       xb_string_append_union (xpath, "components/component/id[text()='%s']/../pkgname/..", id);
-       xb_string_append_union (xpath, "components/component[@type='webapp']/id[text()='%s']/..", id);
+       if (origin && *origin) {
+               xb_string_append_union (xpath, 
"components[@origin='%s']/component/id[text()='%s']/../pkgname/..", origin, id);
+               xb_string_append_union (xpath, 
"components[@origin='%s']/component[@type='webapp']/id[text()='%s']/..", origin, id);
+       } else {
+               xb_string_append_union (xpath, "components/component/id[text()='%s']/../pkgname/..", id);
+               xb_string_append_union (xpath, "components/component[@type='webapp']/id[text()='%s']/..", id);
+       }
        xb_string_append_union (xpath, "component/id[text()='%s']/..", id);
        components = xb_silo_query (priv->silo, xpath->str, 0, &error_local);
        if (components == NULL) {


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