[gnome-software] Find the best AppSteam component when matching any prefixes
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Find the best AppSteam component when matching any prefixes
- Date: Tue, 26 Apr 2016 21:01:23 +0000 (UTC)
commit 5d59f8121635c3ba72d9d10fd9496ecd6812b0e5
Author: Richard Hughes <richard hughsie com>
Date: Tue Apr 26 21:58:58 2016 +0100
Find the best AppSteam component when matching any prefixes
If an application is added in XML without a prefix AND available in AppStream
metadata with a prefix we need to make sure we resolve with the application
that provides the ability to install the application rather than just the first
we find.
src/plugins/gs-plugin-appstream.c | 35 +++++++++++++++++++++++++++++------
1 files changed, 29 insertions(+), 6 deletions(-)
---
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index df1643d..35d5987 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -247,6 +247,7 @@ gs_plugin_refine_from_id (GsPlugin *plugin,
{
GsPluginData *priv = gs_plugin_get_data (plugin);
const gchar *id;
+ guint i;
AsApp *item = NULL;
/* unfound */
@@ -256,13 +257,35 @@ gs_plugin_refine_from_id (GsPlugin *plugin,
id = gs_app_get_id (app);
if (id == NULL)
return TRUE;
- item = as_store_get_app_by_id (priv->store, id);
- if (item == NULL &&
- gs_app_has_quirk (app, AS_APP_QUIRK_MATCH_ANY_PREFIX)) {
- item = as_store_get_app_by_id_ignore_prefix (priv->store, id);
- if (item != NULL)
- g_debug ("found %s for wildcard %s", as_app_get_id (item), id);
+
+ /* find the best app when matching any prefixes */
+ if (gs_app_has_quirk (app, AS_APP_QUIRK_MATCH_ANY_PREFIX)) {
+ g_autoptr(GPtrArray) items = NULL;
+ items = as_store_get_apps_by_id (priv->store, id);
+ for (i = 0; i < items->len; i++) {
+ AsApp *item_tmp = NULL;
+
+ /* does the app have an installation method */
+ item_tmp = g_ptr_array_index (items, i);
+ if (as_app_get_pkgname_default (item_tmp) == NULL &&
+ as_app_get_bundle_default (item_tmp) == NULL) {
+ g_debug ("not using %s for wildcard as "
+ "no bundle or pkgname",
+ as_app_get_id (item_tmp));
+ continue;
+ }
+
+ /* we could match more than one, so list all and return
+ * the last entry -- fingers crossed it's only one... */
+ g_debug ("found %s for wildcard %s",
+ as_app_get_id (item_tmp), id);
+ item = item_tmp;
+ }
+ } else {
+ item = as_store_get_app_by_id (priv->store, id);
}
+
+ /* nothing found */
if (item == NULL)
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]