diff options
author | Richard Hughes <richard@hughsie.com> | 2016-08-03 20:32:13 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2016-08-03 20:33:45 +0100 |
commit | 8b58bc974bca72fc323074f3df1089f2461e00a0 (patch) | |
tree | cdefda0e41c933d64bc1587660cef6427143467c | |
parent | 7635f2af0b456d193ca3f480aa9eaab7cf3499f8 (diff) | |
download | appstream-glib-8b58bc974bca72fc323074f3df1089f2461e00a0.tar.gz |
Always use wildcards when adding apps to the store
It's never right to do an explicit check; if we add a system-wide AppStream
web-app and then a per-user .desktop version we actually want them to match.
The same is true for a per-system app with a per-user override.
-rw-r--r-- | libappstream-glib/as-store.c | 55 |
1 files changed, 19 insertions, 36 deletions
diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c index e13a58e..1023cb5 100644 --- a/libappstream-glib/as-store.c +++ b/libappstream-glib/as-store.c @@ -879,9 +879,20 @@ as_store_remove_app_by_id (AsStore *store, const gchar *id) as_store_perhaps_emit_changed (store, "remove-app-by-id"); } -static void -as_store_add_app_internal (AsStore *store, AsApp *app, - AsStoreSearchFlags search_flags) +/** + * as_store_add_app: + * @store: a #AsStore instance. + * @app: a #AsApp instance. + * + * Adds an application to the store. If a lower priority application has already + * been added then this new application will replace it. + * + * Additionally only applications where the kind is known will be added. + * + * Since: 0.1.0 + **/ +void +as_store_add_app (AsStore *store, AsApp *app) { AsApp *item = NULL; AsStorePrivate *priv = GET_PRIVATE (store); @@ -900,12 +911,7 @@ as_store_add_app_internal (AsStore *store, AsApp *app, /* find the item */ if (priv->add_flags & AS_STORE_ADD_FLAG_USE_UNIQUE_ID) { - if ((search_flags & AS_STORE_SEARCH_FLAG_USE_WILDCARDS) == 0) { - item = g_hash_table_lookup (priv->hash_unique_id, - as_app_get_unique_id (app)); - } else { - item = as_store_get_app_by_app (store, app); - } + item = as_store_get_app_by_app (store, app); } else { apps = g_hash_table_lookup (priv->hash_id, id); if (apps != NULL && apps->len > 0) @@ -1032,25 +1038,6 @@ as_store_add_app_internal (AsStore *store, AsApp *app, as_store_perhaps_emit_changed (store, "add-app"); } -/** - * as_store_add_app: - * @store: a #AsStore instance. - * @app: a #AsApp instance. - * - * Adds an application to the store. If a lower priority application has already - * been added then this new application will replace it. - * - * Additionally only applications where the kind is known will be added. - * - * Since: 0.1.0 - **/ -void -as_store_add_app (AsStore *store, AsApp *app) -{ - as_store_add_app_internal (store, app, - AS_STORE_SEARCH_FLAG_USE_WILDCARDS); -} - static void as_store_match_addons_app (AsStore *store, AsApp *app) { @@ -1305,8 +1292,7 @@ as_store_from_root (AsStore *store, as_app_set_origin (app, origin_app); if (source_filename != NULL) as_app_set_source_file (app, source_filename); - as_store_add_app_internal (store, app, - AS_STORE_SEARCH_FLAG_NONE); + as_store_add_app (store, app); } /* add addon kinds to their parent AsApp */ @@ -1394,10 +1380,8 @@ as_store_load_yaml_file (AsStore *store, if (!as_app_node_parse_dep11 (app, app_n, ctx, error)) return FALSE; as_app_set_origin (app, priv->origin); - if (as_app_get_id (app) != NULL) { - as_store_add_app_internal (store, app, - AS_STORE_SEARCH_FLAG_NONE); - } + if (as_app_get_id (app) != NULL) + as_store_add_app (store, app); } /* emit changed */ @@ -2504,8 +2488,7 @@ as_store_load_installed (AsStore *store, /* set lower priority than AppStream entries */ as_app_set_priority (app, -1); - as_store_add_app_internal (store, app, - AS_STORE_SEARCH_FLAG_USE_WILDCARDS); + as_store_add_app (store, app); } /* emit changed */ |