[gnome-software/wip/hughsie/prefer-desktop-for-pkgname-search] Ensure all applications with addons are shown in the updates panel



commit 29e47561d8fb1133d1289258b962abb473f72546
Author: Richard Hughes <richard hughsie com>
Date:   Wed Jun 12 13:44:40 2019 +0100

    Ensure all applications with addons are shown in the updates panel
    
    Prefer 'desktop' applications when matching the package name to the AppStream
    ID, as addons are not shown in the updates panel and applications are.
    
    Also, only match against one component rather than inheriting properties from
    all components that match the package name.

 plugins/core/gs-plugin-appstream.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)
---
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index 4b587d56..38978f2e 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -751,16 +751,17 @@ gs_plugin_refine_from_pkgname (GsPlugin *plugin,
        /* find all apps when matching any prefixes */
        for (guint j = 0; j < sources->len; j++) {
                const gchar *pkgname = g_ptr_array_index (sources, j);
-               g_autofree gchar *xpath = NULL;
                g_autoptr(GRWLockReaderLocker) locker = NULL;
-               g_autoptr(GPtrArray) components = NULL;
+               g_autoptr(GString) xpath = g_string_new (NULL);
+               g_autoptr(XbNode) component = NULL;
 
                locker = g_rw_lock_reader_locker_new (&priv->silo_lock);
 
-               xpath = g_strdup_printf ("components/component/pkgname[text()='%s']/..",
-                                        pkgname);
-               components = xb_silo_query (priv->silo, xpath, 0, &error_local);
-               if (components == NULL) {
+               /* prefer desktop apps and then fallback to anything else */
+               xb_string_append_union (xpath, 
"components/component[@type='desktop']/pkgname[text()='%s']/..", pkgname);
+               xb_string_append_union (xpath, "components/component/pkgname[text()='%s']/..", pkgname);
+               component = xb_silo_query_first (priv->silo, xpath->str, &error_local);
+               if (component == NULL) {
                        if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                                continue;
                        if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
@@ -768,13 +769,9 @@ gs_plugin_refine_from_pkgname (GsPlugin *plugin,
                        g_propagate_error (error, g_steal_pointer (&error_local));
                        return FALSE;
                }
-               for (guint i = 0; i < components->len; i++) {
-                       XbNode *component = g_ptr_array_index (components, i);
-                       if (!gs_appstream_refine_app (plugin, app, priv->silo,
-                                                     component, flags, error))
-                               return FALSE;
-                       gs_plugin_appstream_set_compulsory_quirk (app, component);
-               }
+               if (!gs_appstream_refine_app (plugin, app, priv->silo, component, flags, error))
+                       return FALSE;
+               gs_plugin_appstream_set_compulsory_quirk (app, component);
        }
 
        /* success */


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