Skip to content

Commit

Permalink
search: Fix printing app ID with no .desktop suffix
Browse files Browse the repository at this point in the history
In flatpak#4535 it was brough to light
that the search command strips the ".desktop" suffix from app IDs even
if they genuinely end in .desktop. This commit fixes the reverse issue
now that we've ported to libappstream: don't include the .desktop suffix
even if it's present in the id of the appstream component, which it
sometimes is.

Fortunately we already ignore any components that don't have flatpak
<bundle> elements, so we can unambiguously get the ID there.
  • Loading branch information
mwleeds committed Nov 10, 2021
1 parent 8187fc6 commit 98ba733
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/flatpak-builtins-search.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,23 @@ compare_apps (MatchResult *a, AsComponent *b)
return !as_app_equal (a->app, b);
}

/* as_component_get_id() returns the ID potentially with a .desktop suffix, so
* this gets the flatpak app ID via the bundle element
*/
static char *
component_get_id_no_suffix (AsComponent *app)
{
AsBundle *app_bundle = as_component_get_bundle (app, AS_BUNDLE_KIND_FLATPAK);
const char *app_ref = as_bundle_get_id (app_bundle);
g_autoptr(FlatpakDecomposed) app_decomposed = flatpak_decomposed_new_from_ref (app_ref, NULL);
return flatpak_decomposed_dup_id (app_decomposed);
}

static void
print_app (Column *columns, MatchResult *res, FlatpakTablePrinter *printer)
{
const char *version = as_app_get_version (res->app);
const char *id = as_component_get_id (res->app);
const char *id = component_get_id_no_suffix (res->app);
const char *name = as_component_get_name (res->app);
const char *comment = as_component_get_summary (res->app);
guint i;
Expand Down

0 comments on commit 98ba733

Please sign in to comment.