[gnome-software/gnome-3-20] Remove return-success for failure workarounds in plugins



commit d83130f73a644959485f393c2a0bccba0ac6788b
Author: Richard Hughes <richard hughsie com>
Date:   Fri Mar 4 09:32:06 2016 +0000

    Remove return-success for failure workarounds in plugins

 src/gs-plugin-loader.c          |    2 +-
 src/plugins/gs-plugin-fwupd.c   |   19 +++++--------------
 src/plugins/gs-plugin-xdg-app.c |   11 ++---------
 3 files changed, 8 insertions(+), 24 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 704d5bb..676767c 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -231,7 +231,7 @@ gs_plugin_loader_run_refine (GsPluginLoader *plugin_loader,
                ret = plugin_func (plugin, list, flags, cancellable, &error_local);
                if (!ret) {
                        g_warning ("failed to call %s on %s: %s",
-                                  "gs_plugin_refine", plugin->name,
+                                  function_name, plugin->name,
                                   error_local->message);
                        continue;
                }
diff --git a/src/plugins/gs-plugin-fwupd.c b/src/plugins/gs-plugin-fwupd.c
index 2e49158..ab2c55f 100644
--- a/src/plugins/gs-plugin-fwupd.c
+++ b/src/plugins/gs-plugin-fwupd.c
@@ -117,7 +117,6 @@ static gboolean
 gs_plugin_startup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
 {
        gsize len;
-       g_autoptr(GError) error_local = NULL;
        g_autofree gchar *data = NULL;
        g_autoptr(GDBusConnection) conn = NULL;
        g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&plugin->priv->mutex);
@@ -135,10 +134,10 @@ gs_plugin_startup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
                                                     FWUPD_DBUS_PATH,
                                                     FWUPD_DBUS_INTERFACE,
                                                     NULL,
-                                                    &error_local);
+                                                    error);
        if (plugin->priv->proxy == NULL) {
-               g_warning ("Failed to start fwupd: %s", error_local->message);
-               return TRUE;
+               g_prefix_error (error, "failed to start fwupd: ");
+               return FALSE;
        }
        g_signal_connect (plugin->priv->proxy, "g-signal",
                          G_CALLBACK (gs_plugin_fwupd_changed_cb), plugin);
@@ -271,7 +270,6 @@ gs_plugin_add_update_app (GsPlugin *plugin,
        FwupdDeviceFlags flags = 0;
        GVariant *variant;
        const gchar *key;
-       g_autoptr(GError) error_local = NULL;
        g_autofree gchar *basename = NULL;
        g_autofree gchar *checksum = NULL;
        g_autofree gchar *filename_cache = NULL;
@@ -422,13 +420,6 @@ gs_plugin_add_updates_historical (GsPlugin *plugin,
                                      &error_local);
        if (val == NULL) {
                if (g_error_matches (error_local,
-                                    G_DBUS_ERROR,
-                                    G_DBUS_ERROR_SERVICE_UNKNOWN)) {
-                       /* the fwupd service might be unavailable, continue in that case */
-                       g_debug ("fwupd: Could not get historical updates, service is unknown.");
-                       return TRUE;
-               }
-               if (g_error_matches (error_local,
                                     FWUPD_ERROR,
                                     FWUPD_ERROR_NOTHING_TO_DO))
                        return TRUE;
@@ -494,8 +485,8 @@ gs_plugin_add_updates (GsPlugin *plugin,
                                     G_DBUS_ERROR,
                                     G_DBUS_ERROR_SERVICE_UNKNOWN)) {
                        /* the fwupd service might be unavailable, continue in that case */
-                       g_debug ("fwupd: Could not get updates, service is unknown.");
-                       return TRUE;
+                       g_prefix_error (error, "could not get fwupd updates: ");
+                       return FALSE;
                }
                if (g_error_matches (error_local,
                                     FWUPD_ERROR,
diff --git a/src/plugins/gs-plugin-xdg-app.c b/src/plugins/gs-plugin-xdg-app.c
index 4853f9c..613060b 100644
--- a/src/plugins/gs-plugin-xdg-app.c
+++ b/src/plugins/gs-plugin-xdg-app.c
@@ -677,7 +677,6 @@ gs_plugin_refine_item_origin_ui (GsPlugin *plugin,
 {
        const gchar *origin;
        guint i;
-       g_autoptr(GError) error_local = NULL;
        g_autoptr(GPtrArray) xremotes = NULL;
        g_autoptr(AsProfileTask) ptask = NULL;
 
@@ -719,7 +718,6 @@ gs_plugin_refine_item_origin (GsPlugin *plugin,
                              GError **error)
 {
        guint i;
-       g_autoptr(GError) error_local = NULL;
        g_autoptr(GPtrArray) xremotes = NULL;
        g_autoptr(AsProfileTask) ptask = NULL;
 
@@ -1458,7 +1456,6 @@ gs_plugin_filename_to_app (GsPlugin *plugin,
        g_autoptr(GBytes) appstream_gz = NULL;
        g_autoptr(GBytes) icon_data = NULL;
        g_autoptr(GBytes) metadata = NULL;
-       g_autoptr(GError) error_local = NULL;
        g_autoptr(GFile) file = NULL;
        g_autoptr(GsApp) app = NULL;
        g_autoptr(XdgAppBundleRef) xref_bundle = NULL;
@@ -1474,13 +1471,9 @@ gs_plugin_filename_to_app (GsPlugin *plugin,
 
        /* load bundle */
        file = g_file_new_for_path (filename);
-       xref_bundle = xdg_app_bundle_ref_new (file, &error_local);
+       xref_bundle = xdg_app_bundle_ref_new (file, error);
        if (xref_bundle == NULL) {
-               g_set_error (error,
-                            GS_PLUGIN_ERROR,
-                            GS_PLUGIN_ERROR_NOT_SUPPORTED,
-                            "Error loading bundle: %s",
-                            error_local->message);
+               g_prefix_error (error, "error loading bundle: ");
                return FALSE;
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]