[gnome-software/gnome-3-22] Fix showing wildcard applications from all plugins
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-22] Fix showing wildcard applications from all plugins
- Date: Mon, 7 Nov 2016 13:37:17 +0000 (UTC)
commit faa801a5686413cdbefd415c63b7fad73e81e463
Author: Richard Hughes <richard hughsie com>
Date: Fri Sep 16 09:56:47 2016 +0100
Fix showing wildcard applications from all plugins
Allow duplicating a wildcarded GsAppp with an actual useful GsApp as the former
will be filtered out by the plugin loader.
(cherry picked from commit 4e7a3fa19ef625cd28d0518a19023ba188c1e8e1)
src/gs-app-list.c | 31 ++++++++++++++++++++++++++++---
src/gs-self-test.c | 13 +++++++++++++
2 files changed, 41 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-app-list.c b/src/gs-app-list.c
index fd5b425..c22c397 100644
--- a/src/gs-app-list.c
+++ b/src/gs-app-list.c
@@ -65,6 +65,33 @@ gs_app_list_lookup (GsAppList *list, const gchar *unique_id)
return g_hash_table_lookup (list->hash_by_id, unique_id);
}
+static gboolean
+gs_app_list_check_for_duplicate (GsAppList *list, GsApp *app)
+{
+ GsApp *app_old;
+ const gchar *id;
+ const gchar *id_old = NULL;
+
+ /* does not exist */
+ id = gs_app_get_unique_id (app);
+ app_old = g_hash_table_lookup (list->hash_by_id, id);
+ if (app_old == NULL) {
+ g_debug ("adding %s as nothing matched hash", id);
+ return TRUE;
+ }
+
+ /* existing app is a wildcard */
+ id_old = gs_app_get_unique_id (app_old);
+ if (gs_app_has_quirk (app_old, AS_APP_QUIRK_MATCH_ANY_PREFIX)) {
+ g_debug ("adding %s as %s is a wildcard", id, id_old);
+ return TRUE;
+ }
+
+ /* already exists */
+ g_debug ("not adding duplicate %s as %s already exists", id, id_old);
+ return FALSE;
+}
+
static void
gs_app_list_add_safe (GsAppList *list, GsApp *app)
{
@@ -81,10 +108,8 @@ gs_app_list_add_safe (GsAppList *list, GsApp *app)
}
/* check for duplicate */
- if (g_hash_table_lookup (list->hash_by_id, id) != NULL) {
- g_debug ("not adding duplicate %s", id);
+ if (!gs_app_list_check_for_duplicate (list, app))
return;
- }
#if !AS_CHECK_VERSION(0,6,2)
/* check for duplicate using globs (slower) */
diff --git a/src/gs-self-test.c b/src/gs-self-test.c
index 293a6aa..c976aa3 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -249,6 +249,19 @@ gs_plugin_func (void)
g_assert (gs_app_list_lookup (list, "*/b/c/d/e/f") != NULL);
g_assert (gs_app_list_lookup (list, "x/x/x/x/x/x") == NULL);
g_object_unref (list);
+
+ /* allow duplicating a wildcard */
+ list = gs_app_list_new ();
+ app = gs_app_new ("gimp.desktop");
+ gs_app_add_quirk (app, AS_APP_QUIRK_MATCH_ANY_PREFIX);
+ gs_app_list_add (list, app);
+ g_object_unref (app);
+ app = gs_app_new ("gimp.desktop");
+ gs_app_set_unique_id (app, "system/flatpak/*/*/gimp.desktop/stable");
+ gs_app_list_add (list, app);
+ g_object_unref (app);
+ g_assert_cmpint (gs_app_list_length (list), ==, 2);
+ g_object_unref (list);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]