summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/download.inc22
1 files changed, 14 insertions, 8 deletions
diff --git a/modules/download.inc b/modules/download.inc
index 8c717eb..46f4f14 100644
--- a/modules/download.inc
+++ b/modules/download.inc
@@ -1,25 +1,31 @@
#!/bin/ash
download() {
- curl --location --max-redirs 5 --max-time 15 --connect-timeout 2 "$@"
+ curl --location --max-redirs 5 --max-time 15 --connect-timeout 3 "$@"
}
download_retry() {
- local delay max_time start end ret
- max_time=8
+ local delay total_time start end ret timeout
+ total_time=10
ret=100
if [ "$1" = "--slx-time" ]; then
- max_time="$2"
+ total_time="$2"
shift 2
fi
+ if ! [ "$total_time" -gt 0 ]; then
+ echo "download_retry: passed timeout is not > 0" >&2
+ return 1
+ 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 "$@"
+ end="$start"
+ for delay in 0 1 1 2 2 3 3 3 4 4 4 5 5 5 5 5 5 5 5 5; do
+ timeout=$(( total_time - delay - (end - start) ))
+ [ "$timeout" -gt 0 ] || break
+ sleep "$delay"
+ download --max-time "$timeout" "$@"
ret="$?"
[ "$ret" = 0 ] && return 0
end="$( date +%s )"
- [ "$(( end - start ))" -ge "$max_time" ] && break
- [ -n "$delay" ] && sleep "$delay"
done
return "$ret"
}