diff options
-rw-r--r-- | modules/download.inc | 26 |
1 files 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" } |