summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPhaedrus Leeds <mwleeds@protonmail.com>2021-11-15 11:33:45 -0800
committerPhaedrus Leeds <mwl458@gmail.com>2022-02-17 08:29:20 -0600
commit036542c28b3a05aae26c01e0fd9f889497a97dc5 (patch)
treed1dd1c439b8637068dcf3ba830edce513cc070d5 /app
parent361ec3bc8c10d0199bc6abc5a2d2b0ba46781ce9 (diff)
downloadflatpak-036542c28b3a05aae26c01e0fd9f889497a97dc5.tar.gz
Revert "search: Use <bundle> ID to determine flatpak app ID"
This reverts commit 39de0ef280a98f67d639444cc6ea3bcfa61c0eec. This is implemented differently after the libappstream port.
Diffstat (limited to 'app')
-rw-r--r--app/flatpak-builtins-search.c46
1 files changed, 16 insertions, 30 deletions
diff --git a/app/flatpak-builtins-search.c b/app/flatpak-builtins-search.c
index 3cb65c6d..d2a04895 100644
--- a/app/flatpak-builtins-search.c
+++ b/app/flatpak-builtins-search.c
@@ -194,44 +194,30 @@ as_app_equal (AsApp *app1, AsApp *app2)
}
#endif
-static char *
+/* This returns the app ID with the ".desktop" suffix stripped. In most cases
+ * that is what as_app_get_id_filename() does, but if the ID actually ends in
+ * .desktop it is stripped anyway and e.g. "org.telegram" is returned instead
+ * of "org.telegram.desktop" (which is a bug in appstream-glib). See
+ * https://github.com/hughsie/appstream-glib/issues/420 and
+ * https://github.com/flatpak/flatpak/issues/4535
+ */
+static const char *
_app_get_id_no_suffix (AsApp *app)
{
- const char *id_stripped = NULL;
-#if AS_CHECK_VERSION (0, 5, 15)
- GPtrArray *bundles = NULL;
-
- /* First try using the <bundle> ID which is unambiguously the flatpak ref */
- bundles = as_app_get_bundles (app);
- for (guint i = 0; i < bundles->len; i++)
- {
- g_autoptr(FlatpakDecomposed) decomposed = NULL;
- AsBundle *bundle = g_ptr_array_index (bundles, i);
- if (as_bundle_get_kind (bundle) != AS_BUNDLE_KIND_FLATPAK)
- continue;
-
- decomposed = flatpak_decomposed_new_from_ref (as_bundle_get_id (bundle), NULL);
- if (decomposed != NULL)
- return flatpak_decomposed_dup_id (decomposed);
- }
-#endif
-
- /* Fall back to using the <id> field, which is required by appstream spec,
- * but make sure the .desktop suffix isn't stripped overzealously
- * https://github.com/hughsie/appstream-glib/issues/420
- */
+ const gchar *id_with_suffix = NULL;
+ const gchar *id_stripped = NULL;
+ id_with_suffix = as_app_get_id_no_prefix (app);
id_stripped = as_app_get_id_filename (app);
if (flatpak_is_valid_name (id_stripped, -1, NULL))
- return g_strdup (id_stripped);
+ return id_stripped;
else
{
g_autofree char *id_with_desktop = g_strconcat (id_stripped, ".desktop", NULL);
- const char *id_with_suffix = as_app_get_id_no_prefix (app);
if (flatpak_is_valid_name (id_with_desktop, -1, NULL) &&
g_strcmp0 (id_with_suffix, id_with_desktop) == 0)
- return g_strdup (id_with_suffix);
+ return id_with_suffix;
else
- return g_strdup (id_stripped);
+ return id_stripped;
}
}
@@ -251,7 +237,7 @@ static void
print_app (Column *columns, MatchResult *res, FlatpakTablePrinter *printer)
{
const char *version = as_app_get_version (res->app);
- g_autofree char *id = _app_get_id_no_suffix (res->app);
+ const char *id = _app_get_id_no_suffix (res->app);
const char *name = as_app_get_localized_name (res->app);
const char *comment = as_app_get_localized_comment (res->app);
guint i;
@@ -348,7 +334,7 @@ flatpak_builtin_search (int argc, char **argv, GCancellable *cancellable, GError
guint score = as_app_search_matches (app, search_text);
if (score == 0)
{
- g_autofree char *app_id = _app_get_id_no_suffix (app);
+ const char *app_id = _app_get_id_no_suffix (app);
if (strcasestr (app_id, search_text) != NULL)
score = 50;
else