summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2017-12-07 12:41:00 +0000
committerRichard Hughes <richard@hughsie.com>2017-12-07 12:46:13 +0000
commit1eb3f32d6b004a5534c2136e7c72f9cb745c1c49 (patch)
tree61432a10dbf39794b754848ba79c090db3300820
parenta6f4295ba012d51e7c1f676932b1a2a8062bd3f5 (diff)
downloadappstream-glib-1eb3f32d6b004a5534c2136e7c72f9cb745c1c49.tar.gz
Fix appstream-compose when using new-style desktop IDs
The .desktop suffix is now optional in the AppStream component <id>. Fixes: https://github.com/hughsie/appstream-glib/issues/209
-rw-r--r--client/as-compose.c16
1 files 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,