diff options
author | Simon McVittie <smcv@collabora.com> | 2023-02-08 18:34:05 +0000 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2023-02-08 21:14:17 +0000 |
commit | 3ede5382fa8e7f90d62e72bc72da64277ea254b7 (patch) | |
tree | 71d40bc7f27844b5e0cc30a246d607be35cb0166 | |
parent | 628750d2de7421fe4b26eebd1a6f27c524eb8a7e (diff) | |
download | flatpak-3ede5382fa8e7f90d62e72bc72da64277ea254b7.tar.gz |
dir: If overrides are syntactically invalid, include path in error message
It's unhelpful to say something like "Key file contains line “x” which is
not a key-value pair, group, or comment" without specifying which file
we are talking about.
Signed-off-by: Simon McVittie <smcv@collabora.com>
-rw-r--r-- | common/flatpak-dir-private.h | 1 | ||||
-rw-r--r-- | common/flatpak-dir.c | 9 | ||||
-rw-r--r-- | common/flatpak-installation.c | 2 |
3 files changed, 9 insertions, 3 deletions
diff --git a/common/flatpak-dir-private.h b/common/flatpak-dir-private.h index 950944b3..39be0660 100644 --- a/common/flatpak-dir-private.h +++ b/common/flatpak-dir-private.h @@ -562,6 +562,7 @@ FlatpakDeploy * flatpak_dir_load_deployed (Fla char * flatpak_dir_load_override (FlatpakDir *dir, const char *app_id, gsize *length, + GFile **file_out, GError **error); OstreeRepo * flatpak_dir_get_repo (FlatpakDir *self); gboolean flatpak_dir_ensure_path (FlatpakDir *self, diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index 8cf051ed..fea8a24b 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -2799,6 +2799,7 @@ char * flatpak_dir_load_override (FlatpakDir *self, const char *app_id, gsize *length, + GFile **file_out, GError **error) { g_autoptr(GFile) override_dir = NULL; @@ -2820,6 +2821,9 @@ flatpak_dir_load_override (FlatpakDir *self, return NULL; } + if (file_out != NULL) + *file_out = g_object_ref (file); + return metadata_contents; } @@ -2828,12 +2832,13 @@ flatpak_load_override_keyfile (const char *app_id, gboolean user, GError **error { g_autofree char *metadata_contents = NULL; gsize metadata_size; + g_autoptr(GFile) file = NULL; g_autoptr(GKeyFile) metakey = g_key_file_new (); g_autoptr(FlatpakDir) dir = NULL; dir = user ? flatpak_dir_get_user () : flatpak_dir_get_system_default (); - metadata_contents = flatpak_dir_load_override (dir, app_id, &metadata_size, error); + metadata_contents = flatpak_dir_load_override (dir, app_id, &metadata_size, &file, error); if (metadata_contents == NULL) return NULL; @@ -2841,7 +2846,7 @@ flatpak_load_override_keyfile (const char *app_id, gboolean user, GError **error metadata_contents, metadata_size, 0, error)) - return NULL; + return glnx_prefix_error_null (error, "%s", flatpak_file_get_path_cached (file)); return g_steal_pointer (&metakey); } diff --git a/common/flatpak-installation.c b/common/flatpak-installation.c index c19ef6bc..7dd95a21 100644 --- a/common/flatpak-installation.c +++ b/common/flatpak-installation.c @@ -1714,7 +1714,7 @@ flatpak_installation_load_app_overrides (FlatpakInstallation *self, if (dir == NULL) return NULL; - metadata_contents = flatpak_dir_load_override (dir, app_id, &metadata_size, error); + metadata_contents = flatpak_dir_load_override (dir, app_id, &metadata_size, NULL, error); if (metadata_contents == NULL) return NULL; |