From a30d933ac408ef332dadfb38298d3b3df146d1f9 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Mon, 23 Apr 2018 16:54:30 +0100 Subject: [PATCH] Show a translated warning when the server is limiting downloads --- src/fu-util.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/fu-util.c b/src/fu-util.c index 69e2f42d0..6392aaae3 100644 --- a/src/fu-util.c +++ b/src/fu-util.c @@ -1211,6 +1211,23 @@ fu_util_download_file (FuUtilPrivate *priv, G_CALLBACK (fu_util_download_chunk_cb), priv); status_code = soup_session_send_message (priv->soup_session, msg); g_print ("\n"); + if (status_code == 429) { + g_autofree gchar *str = g_strndup (msg->response_body->data, + msg->response_body->length); + if (g_strcmp0 (str, "Too Many Requests") == 0) { + g_set_error (error, + FWUPD_ERROR, + FWUPD_ERROR_INVALID_FILE, + /* TRANSLATORS: the server is rate-limiting downloads */ + "%s", _("Failed to download due to server limit")); + return FALSE; + } + g_set_error (error, + FWUPD_ERROR, + FWUPD_ERROR_INVALID_FILE, + "Failed to download due to server limit: %s", str); + return FALSE; + } if (status_code != SOUP_STATUS_OK) { g_set_error (error, FWUPD_ERROR,