[gnome-software/1470-never-show-quark-ids-in-user-visible-error-messages] packagekit: Make sure errors are converted to GsPlugin errors
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1470-never-show-quark-ids-in-user-visible-error-messages] packagekit: Make sure errors are converted to GsPlugin errors
- Date: Fri, 1 Oct 2021 11:00:41 +0000 (UTC)
commit 2b732122c35ffa25a4fed2eacc1bd9b9b53b36b5
Author: Milan Crha <mcrha redhat com>
Date: Fri Oct 1 12:56:21 2021 +0200
packagekit: Make sure errors are converted to GsPlugin errors
Some of the functions did not convert errors into the GsPlugin errors,
which could led to incorrect error codes and messages shown to the user.
Also strip any D-Bus related remote error notes, as the PackageKit
can return such too.
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1470
plugins/packagekit/gs-plugin-packagekit.c | 15 ++++++++++++---
plugins/packagekit/gs-plugin-systemd-updates.c | 11 +++++++++--
plugins/packagekit/packagekit-common.c | 5 ++++-
3 files changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index c9e4e49fd..720dc1a49 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -1680,8 +1680,10 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
priv->connection_history = g_bus_get_sync (G_BUS_TYPE_SYSTEM,
cancellable,
error);
- if (priv->connection_history == NULL)
+ if (priv->connection_history == NULL) {
+ gs_plugin_packagekit_error_convert (error);
return FALSE;
+ }
reload_proxy_settings (plugin, cancellable);
@@ -1726,6 +1728,7 @@ gs_plugin_packagekit_refine_history (GsPlugin *plugin,
cancellable,
&error_local);
if (result == NULL) {
+ g_dbus_error_strip_remote_error (error_local);
if (g_error_matches (error_local,
G_DBUS_ERROR,
G_DBUS_ERROR_UNKNOWN_METHOD)) {
@@ -1901,8 +1904,10 @@ gs_plugin_packagekit_local_check_installed (GsPlugin *plugin,
-1);
results = pk_client_resolve (PK_CLIENT (priv->task_local), filter, (gchar **) names,
cancellable, NULL, NULL, error);
- if (results == NULL)
+ if (results == NULL) {
+ gs_plugin_packagekit_error_convert (error);
return FALSE;
+ }
packages = pk_results_get_package_array (results);
if (packages->len > 0) {
gs_app_set_state (app, GS_APP_STATE_UNKNOWN);
@@ -2114,6 +2119,8 @@ gs_plugin_add_updates_historical (GsPlugin *plugin,
return TRUE;
}
+ gs_plugin_packagekit_error_convert (&error_local);
+
g_set_error (error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_INVALID_FORMAT,
@@ -2124,8 +2131,10 @@ gs_plugin_add_updates_historical (GsPlugin *plugin,
/* get the mtime of the results */
mtime = pk_offline_get_results_mtime (error);
- if (mtime == 0)
+ if (mtime == 0) {
+ gs_plugin_packagekit_error_convert (error);
return FALSE;
+ }
/* only return results if successful */
exit_code = pk_results_get_exit_code (results);
diff --git a/plugins/packagekit/gs-plugin-systemd-updates.c b/plugins/packagekit/gs-plugin-systemd-updates.c
index cc721c208..e6594b604 100644
--- a/plugins/packagekit/gs-plugin-systemd-updates.c
+++ b/plugins/packagekit/gs-plugin-systemd-updates.c
@@ -83,6 +83,7 @@ gs_plugin_systemd_update_cache (GsPlugin *plugin, GError **error)
PK_OFFLINE_ERROR_NO_DATA)) {
return TRUE;
}
+ gs_plugin_packagekit_error_convert (&error_local);
g_set_error (error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_INVALID_FORMAT,
@@ -451,8 +452,10 @@ gs_plugin_update_cancel (GsPlugin *plugin,
return TRUE;
/* cancel offline update */
- if (!gs_systemd_call_cancel (plugin, cancellable, error))
+ if (!gs_systemd_call_cancel (plugin, cancellable, error)) {
+ gs_plugin_packagekit_error_convert (error);
return FALSE;
+ }
/* don't rely on the file monitor */
gs_plugin_systemd_updates_refresh_is_triggered (plugin, cancellable);
@@ -470,5 +473,9 @@ gs_plugin_app_upgrade_trigger (GsPlugin *plugin,
/* only process this app if was created by this plugin */
if (g_strcmp0 (gs_app_get_management_plugin (app), "packagekit") != 0)
return TRUE;
- return gs_systemd_call_trigger_upgrade (plugin, PK_OFFLINE_ACTION_REBOOT, cancellable, error);
+ if (!gs_systemd_call_trigger_upgrade (plugin, PK_OFFLINE_ACTION_REBOOT, cancellable, error)) {
+ gs_plugin_packagekit_error_convert (error);
+ return FALSE;
+ }
+ return TRUE;
}
diff --git a/plugins/packagekit/packagekit-common.c b/plugins/packagekit/packagekit-common.c
index c644ff993..16b53727a 100644
--- a/plugins/packagekit/packagekit-common.c
+++ b/plugins/packagekit/packagekit-common.c
@@ -77,7 +77,10 @@ gs_plugin_packagekit_error_convert (GError **error)
if (error == NULL)
return FALSE;
- /* this are allowed for low-level errors */
+ if (*error != NULL)
+ g_dbus_error_strip_remote_error (*error);
+
+ /* these are allowed for low-level errors */
if (gs_utils_error_convert_gio (error))
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]