From 6ab53111dba850aaa930f79efef0d49966a0159c Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 15 Sep 2017 09:35:25 +0100 Subject: [PATCH] Never fallback to an offline update from client code UEFI updates don't need to be retried since a785a1c. If the call to Install() failed with NOT_SUPPORTED we can just show the error rather than doing the little dance and involving the offline pending database for no reason. Fixes some of https://github.com/hughsie/fwupd/issues/255 --- src/fu-util.c | 42 ++++++++++-------------------------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/src/fu-util.c b/src/fu-util.c index 998320cb0..d8380d65b 100644 --- a/src/fu-util.c +++ b/src/fu-util.c @@ -314,32 +314,6 @@ fu_util_get_devices (FuUtilPrivate *priv, gchar **values, GError **error) return TRUE; } -static gboolean -fu_util_install_with_fallback (FuUtilPrivate *priv, const gchar *id, - const gchar *filename, GError **error) -{ - g_autoptr(GError) error_local = NULL; - - /* install with flags chosen by the user */ - if (fwupd_client_install (priv->client, id, filename, priv->flags, - NULL, &error_local)) - return TRUE; - - /* some other failure */ - if ((priv->flags & FWUPD_INSTALL_FLAG_OFFLINE) > 0 || - !g_error_matches (error_local, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED)) { - g_propagate_error (error, error_local); - error_local = NULL; - return FALSE; - } - - /* TRANSLATOR: the plugin only supports offline */ - g_print ("%s...\n", _("Retrying as an offline update")); - priv->flags |= FWUPD_INSTALL_FLAG_OFFLINE; - return fwupd_client_install (priv->client, id, filename, priv->flags, - NULL, error); -} - static gboolean fu_util_install (FuUtilPrivate *priv, gchar **values, GError **error) { @@ -358,8 +332,8 @@ fu_util_install (FuUtilPrivate *priv, gchar **values, GError **error) return FALSE; } - /* install with flags chosen by the user then falling back to offline */ - return fu_util_install_with_fallback (priv, id, values[0], error); + /* install with flags chosen by the user */ + return fwupd_client_install (priv->client, id, values[0], priv->flags, NULL, error); } static gboolean @@ -1366,10 +1340,12 @@ fu_util_update_device_with_release (FuUtilPrivate *priv, if (fwupd_remote_get_kind (remote) == FWUPD_REMOTE_KIND_LOCAL) { const gchar *fn_cache = fwupd_remote_get_filename_cache (remote); g_autofree gchar *path = g_path_get_dirname (fn_cache); + + /* install with flags chosen by the user */ fn = g_build_filename (path, uri_tmp, NULL); - return fu_util_install_with_fallback (priv, - fwupd_device_get_id (dev), - fn, error); + return fwupd_client_install (priv->client, + fwupd_device_get_id (dev), + fn, priv->flags, NULL, error); } uri = fwupd_remote_build_uri (remote, uri_tmp, error); @@ -1395,7 +1371,9 @@ fu_util_update_device_with_release (FuUtilPrivate *priv, g_print ("Updating %s on %s...\n", fwupd_release_get_version (rel), fwupd_device_get_name (dev)); - return fu_util_install_with_fallback (priv, fwupd_device_get_id (dev), fn, error); + return fwupd_client_install (priv->client, + fwupd_device_get_id (dev), fn, + priv->flags, NULL, error); } static gboolean