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
This commit is contained in:
Matthew Leeds
2018-02-07 13:34:25 -08:00
committed by Atomic Bot
parent 728bb4d02e
commit b80191fdcd
2 changed files with 15 additions and 8 deletions

View File

@@ -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);

View File

@@ -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);