[gnome-software/1699-crash-under-gs_plugin_flatpak_find_app_by_ref] flatpak: Improve error message when cannot install app from a filtered remote
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1699-crash-under-gs_plugin_flatpak_find_app_by_ref] flatpak: Improve error message when cannot install app from a filtered remote
- Date: Mon, 20 Jun 2022 19:19:36 +0000 (UTC)
commit ae0708842ba2d7c6eac0263e70dfa839f3cbe912
Author: Milan Crha <mcrha redhat com>
Date: Mon Jun 20 21:14:47 2022 +0200
flatpak: Improve error message when cannot install app from a filtered remote
The filter can disallow install of the application the user tried to install
from a .flatpakref file, thus provide a nicer error message, better understandable
to the users.
plugins/flatpak/gs-plugin-flatpak.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
---
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index bd0bacd49..a62e686fc 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -1303,6 +1303,28 @@ gs_plugin_app_install (GsPlugin *plugin,
already_installed = TRUE;
g_clear_error (&error_local);
} else {
+ if (g_error_matches (error_local, FLATPAK_ERROR,
FLATPAK_ERROR_REF_NOT_FOUND)) {
+ const gchar *origin = gs_app_get_origin (app);
+ if (origin != NULL) {
+ g_autoptr(FlatpakRemote) remote = NULL;
+ remote = flatpak_installation_get_remote_by_name
(gs_flatpak_get_installation (flatpak, interactive),
+ origin,
cancellable, NULL);
+ if (remote != NULL) {
+ g_autofree gchar *filter = flatpak_remote_get_filter
(remote);
+ if (filter != NULL && *filter != '\0') {
+ /* It's a filtered remote, create a user
friendly error message for it */
+ g_autoptr(GError) error_tmp = NULL;
+ g_set_error (&error_tmp, GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_FAILED,
+ _("Remote ā%sā doesn't allow
install of ā%sā, possibly due to its filter. Remove the filter and repeat the install. Detailed error: %s"),
+ flatpak_remote_get_title
(remote),
+ gs_app_get_name (app),
+ error_local->message);
+ g_clear_error (&error_local);
+ error_local = g_steal_pointer (&error_tmp);
+ }
+ }
+ }
+ }
g_propagate_error (error, g_steal_pointer (&error_local));
gs_flatpak_error_convert (error);
gs_app_set_state_recover (app);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]