[pacman-dev] [PATCH 1/1] RFC: handle soft failure in downloads
Christian Hesse
list at eworm.de
Thu May 20 21:05:09 UTC 2021
From: Christian Hesse <mail at eworm.de>
A server can indicate a soft failure by returning 412 (Precondition
Failed). Only a warning (instead of error) message is logged and
download is retried with next server, without counting server error.
This http code can be used by servers that are not expected to be
complete, for example when serving a local cache.
Signed-off-by: Christian Hesse <mail at eworm.de>
---
lib/libalpm/dload.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index f6a4f012..7116cb03 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -515,13 +515,23 @@ static int curl_check_finished_download(CURLM *curlm, CURLMsg *msg,
if(!payload->errors_ok) {
handle->pm_errno = ALPM_ERR_RETRIEVE;
- /* non-translated message is same as libcurl */
- snprintf(payload->error_buffer, sizeof(payload->error_buffer),
+ if(payload->respcode == 412) {
+ /* A server can indicate a soft failure by returning 412
+ (Precondition Failed). Only a debug message is logged and
+ download is retried with next server, without counting
+ server error. */
+ _alpm_log(handle, ALPM_LOG_WARNING,
+ _("file '%s' is currently not available from %s\n"),
+ payload->remote_name, hostname);
+ } else {
+ /* non-translated message is same as libcurl */
+ snprintf(payload->error_buffer, sizeof(payload->error_buffer),
"The requested URL returned error: %ld", payload->respcode);
- _alpm_log(handle, ALPM_LOG_ERROR,
+ _alpm_log(handle, ALPM_LOG_ERROR,
_("failed retrieving file '%s' from %s : %s\n"),
payload->remote_name, hostname, payload->error_buffer);
- server_soft_error(handle, payload->fileurl);
+ server_soft_error(handle, payload->fileurl);
+ }
}
if(curl_retry_next_server(curlm, curl, payload) == 0) {
(*active_downloads_num)++;
More information about the pacman-dev
mailing list