From d422cf9d15ad7c411f6d51fac5299b895d8870af Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 23 May 2022 12:17:38 +0200 Subject: [download] Increase default retry timeout, add --slx-time option --- modules/download.inc | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/modules/download.inc b/modules/download.inc index c1b0912..8c717eb 100644 --- a/modules/download.inc +++ b/modules/download.inc @@ -1,18 +1,26 @@ #!/bin/ash download() { - curl --location --max-redirs 5 --max-time 7 --connect-timeout 2 "$@" + curl --location --max-redirs 5 --max-time 15 --connect-timeout 2 "$@" } download_retry() { - for delay in 1 2 3 ""; do - if download --retry-max-time 12 "$@"; then - return 0 - fi - if [ -n "$delay" ]; then - sleep "$delay" - fi + local delay max_time start end ret + max_time=8 + ret=100 + if [ "$1" = "--slx-time" ]; then + max_time="$2" + shift 2 + fi + start="$( date +%s )" + for delay in 1 2 2 3 3 3 4 4 4 5 5 5 5 5 5 5 5 5 ""; do + download "$@" + ret="$?" + [ "$ret" = 0 ] && return 0 + end="$( date +%s )" + [ "$(( end - start ))" -ge "$max_time" ] && break + [ -n "$delay" ] && sleep "$delay" done - return 1 + return "$ret" } -- cgit v1.2.3-55-g7522