summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Leeds <matthew.leeds@endlessm.com>2018-02-07 13:34:25 -0800
committerAtomic Bot <atomic-devel@projectatomic.io>2018-02-09 11:08:40 +0000
commitb80191fdcd3df13905c2c900709c81753df501dd (patch)
tree653e751d83ec439a89ed64a468a2f8548d3a774b
parent728bb4d02e723966319981631649b5a4f6822f7e (diff)
downloadflatpak-b80191fdcd3df13905c2c900709c81753df501dd.tar.gz
app: Print a warning if xa.metadata doesn't exist
All flatpaks built using version 0.9.4 or newer should have the xa.metadata field in the commit metadata, so warn if it doesn't exist. This commit changes the info command to print a warning rather than nothing and changes the info-remote command to print a warning rather than error out. Closes: #1351 Approved by: alexlarsson
-rw-r--r--app/flatpak-builtins-info-remote.c19
-rw-r--r--app/flatpak-builtins-info.c4
2 files changed, 15 insertions, 8 deletions
diff --git a/app/flatpak-builtins-info-remote.c b/app/flatpak-builtins-info-remote.c
index f3ecce4e..d81530a4 100644
--- a/app/flatpak-builtins-info-remote.c
+++ b/app/flatpak-builtins-info-remote.c
@@ -174,7 +174,13 @@ flatpak_builtin_info_remote (int argc, char **argv, GCancellable *cancellable, G
commit_metadata = g_variant_get_child_value (commit_v, 0);
g_variant_lookup (commit_metadata, "xa.metadata", "&s", &xa_metadata);
if (xa_metadata == NULL)
- return flatpak_fail (error, "Commit has no metadata");
+ g_printerr (_("Warning: Commit has no flatpak metadata\n"));
+ else
+ {
+ metakey = g_key_file_new ();
+ if (!g_key_file_load_from_data (metakey, xa_metadata, -1, 0, error))
+ return FALSE;
+ }
#ifdef FLATPAK_ENABLE_P2P
g_variant_lookup (commit_metadata, "ostree.collection-binding", "&s", &collection_id);
@@ -186,10 +192,6 @@ flatpak_builtin_info_remote (int argc, char **argv, GCancellable *cancellable, G
if (g_variant_lookup (commit_metadata, "xa.download-size", "t", &download_size))
download_size = GUINT64_FROM_BE (download_size);
- metakey = g_key_file_new ();
- if (!g_key_file_load_from_data (metakey, xa_metadata, -1, 0, error))
- return FALSE;
-
parts = g_strsplit (ref, "/", 0);
formatted_installed_size = g_format_size (installed_size);
formatted_download_size = g_format_size (download_size);
@@ -207,7 +209,7 @@ flatpak_builtin_info_remote (int argc, char **argv, GCancellable *cancellable, G
g_print ("%s%s%s %s\n", on, _("Parent:"), off, parent ? parent : "-");
g_print ("%s%s%s %s\n", on, _("Download size:"), off, formatted_download_size);
g_print ("%s%s%s %s\n", on, _("Installed size:"), off, formatted_installed_size);
- if (strcmp (parts[0], "app") == 0)
+ if (strcmp (parts[0], "app") == 0 && metakey != NULL)
{
g_autofree char *runtime = NULL;
runtime = g_key_file_get_string (metakey, "Application", "runtime", error);
@@ -287,8 +289,9 @@ flatpak_builtin_info_remote (int argc, char **argv, GCancellable *cancellable, G
c_m = g_variant_get_child_value (c_v, 0);
g_variant_lookup (c_m, "xa.metadata", "&s", &xa_metadata);
if (xa_metadata == NULL)
- return flatpak_fail (error, "Commit %s has no metadata", c);
- g_print ("%s", xa_metadata);
+ g_printerr (_("Warning: Commit %s has no flatpak metadata\n"), c);
+ else
+ g_print ("%s", xa_metadata);
}
g_free (c);
diff --git a/app/flatpak-builtins-info.c b/app/flatpak-builtins-info.c
index d611a232..2367adaf 100644
--- a/app/flatpak-builtins-info.c
+++ b/app/flatpak-builtins-info.c
@@ -181,6 +181,7 @@ flatpak_builtin_info (int argc, char **argv, GCancellable *cancellable, GError *
const gchar *body = NULL;
g_autofree char *parent = NULL;
const char *latest;
+ const char *xa_metadata = NULL;
const char *collection_id = NULL;
latest = flatpak_dir_read_latest (dir, origin, ref, NULL, NULL, NULL);
@@ -196,6 +197,9 @@ flatpak_builtin_info (int argc, char **argv, GCancellable *cancellable, GError *
formatted_timestamp = format_timestamp (timestamp);
commit_metadata = g_variant_get_child_value (commit_v, 0);
+ g_variant_lookup (commit_metadata, "xa.metadata", "&s", &xa_metadata);
+ if (xa_metadata == NULL)
+ g_printerr (_("Warning: Commit has no flatpak metadata\n"));
#ifdef FLATPAK_ENABLE_P2P
g_variant_lookup (commit_metadata, "ostree.collection-binding", "&s", &collection_id);