[gnome-software/wip/hughsie/fix-alternates-regression: 3/5] Do not add the alternate wildcard in the plugin loader
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/fix-alternates-regression: 3/5] Do not add the alternate wildcard in the plugin loader
- Date: Mon, 8 Oct 2018 16:22:54 +0000 (UTC)
commit 6f6ffae9bbb46ac77666097affe0291038779406
Author: Richard Hughes <richard hughsie com>
Date: Mon Oct 8 17:13:34 2018 +0100
Do not add the alternate wildcard in the plugin loader
We can trivially do it in the plugin code, and there we can correctly
deduplicate the wildcard matches without playing games with the unique ID.
lib/gs-plugin-loader.c | 12 +++---------
plugins/core/gs-appstream.c | 4 ++++
plugins/dummy/gs-self-test.c | 4 ++--
3 files changed, 9 insertions(+), 11 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index f8f5cf0a..1cde3b12 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -3511,17 +3511,11 @@ gs_plugin_loader_job_process_async (GsPluginLoader *plugin_loader,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_SETUP_ACTION);
}
- /* always add the original app to the list so it can be sorted */
+ /* get alternates is unusual in that it needs an app input and a list
+ * output -- so undo the helpful app add in gs_plugin_job_set_app() */
if (action == GS_PLUGIN_ACTION_GET_ALTERNATES) {
- GsApp *app = gs_plugin_job_get_app (plugin_job);
GsAppList *list = gs_plugin_job_get_list (plugin_job);
-
- /* also add the wildcard match */
- if (!gs_app_has_quirk (app, AS_APP_QUIRK_MATCH_ANY_PREFIX)) {
- g_autoptr(GsApp) app2 = gs_app_new (gs_app_get_id (app));
- gs_app_add_quirk (app2, AS_APP_QUIRK_MATCH_ANY_PREFIX);
- gs_app_list_add (list, app2);
- }
+ gs_app_list_remove_all (list);
}
/* check required args */
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index 06f8288a..ef2c6ccb 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -1089,6 +1089,10 @@ gs_appstream_add_alternates (GsPlugin *plugin,
AsApp *item = g_ptr_array_index (apps, i);
GPtrArray *sources = gs_app_get_sources (app);
+ /* actual ID */
+ if (g_strcmp0 (as_app_get_id (item), gs_app_get_id (app)) == 0)
+ _g_ptr_array_add_str_uniq (ids, as_app_get_id (item));
+
/* new ID -> old ID */
gs_appstream_add_alternates_old_id (ids, item, gs_app_get_id (app));
diff --git a/plugins/dummy/gs-self-test.c b/plugins/dummy/gs-self-test.c
index 3216a742..ddc3e868 100644
--- a/plugins/dummy/gs-self-test.c
+++ b/plugins/dummy/gs-self-test.c
@@ -462,10 +462,10 @@ gs_plugins_dummy_search_alternate_func (GsPluginLoader *plugin_loader)
/* make sure there is the original app, and the alternate */
g_assert_cmpint (gs_app_list_length (list), ==, 2);
app_tmp = gs_app_list_index (list, 0);
- g_assert_cmpstr (gs_app_get_id (app_tmp), ==, "zeus.desktop");
+ g_assert_cmpstr (gs_app_get_id (app_tmp), ==, "chiron.desktop");
g_assert_cmpint (gs_app_get_kind (app_tmp), ==, AS_APP_KIND_DESKTOP);
app_tmp = gs_app_list_index (list, 1);
- g_assert_cmpstr (gs_app_get_id (app_tmp), ==, "chiron.desktop");
+ g_assert_cmpstr (gs_app_get_id (app_tmp), ==, "zeus.desktop");
g_assert_cmpint (gs_app_get_kind (app_tmp), ==, AS_APP_KIND_DESKTOP);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]