From 1eb3f32d6b004a5534c2136e7c72f9cb745c1c49 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Thu, 7 Dec 2017 12:41:00 +0000 Subject: Fix appstream-compose when using new-style desktop IDs The .desktop suffix is now optional in the AppStream component . Fixes: https://github.com/hughsie/appstream-glib/issues/209 --- client/as-compose.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/client/as-compose.c b/client/as-compose.c index 6d63c55..55b35b1 100644 --- a/client/as-compose.c +++ b/client/as-compose.c @@ -402,7 +402,7 @@ main (int argc, char **argv) g_auto(GStrv) intl_domains = NULL; g_autoptr(AsApp) app_appdata = NULL; g_autoptr(AsApp) app_desktop = NULL; - g_autofree gchar *desktop_basename = NULL; + g_autoptr(GString) desktop_basename = NULL; g_autofree gchar *desktop_path = NULL; const gchar *appdata_id; @@ -455,12 +455,16 @@ main (int argc, char **argv) as_store_add_app (store, app_appdata); + /* use the ID from the AppData file if it was found */ appdata_id = as_app_get_id (app_appdata); - if (appdata_id != NULL) - desktop_basename = g_strdup (appdata_id); - else - desktop_basename = g_strconcat (app_name, ".desktop", NULL); - desktop_path = g_build_filename (prefix, "share/applications", desktop_basename, NULL); + desktop_basename = g_string_new (appdata_id != NULL ? appdata_id : app_name); + + /* append the .desktop suffix if using a new-style name */ + if (!g_str_has_suffix (desktop_basename->str, ".desktop")) + g_string_append (desktop_basename, ".desktop"); + desktop_path = g_build_filename (prefix, "share", "applications", + desktop_basename->str, NULL); + g_debug ("looking for %s", desktop_path); if (g_file_test (desktop_path, G_FILE_TEST_EXISTS)) { app_desktop = load_desktop (prefix, -- cgit v1.2.1