summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2022-05-23 12:17:38 +0200
committerSimon Rettberg2022-05-23 12:17:38 +0200
commitd422cf9d15ad7c411f6d51fac5299b895d8870af (patch)
treee5a259edf28bac7941d7894b88bda0ce930b62ca
parent[dev] dev_find_partitions: Workaround for missing PARTN/NAME on CentOS 7 (diff)
downloadslx-tools-d422cf9d15ad7c411f6d51fac5299b895d8870af.tar.gz
slx-tools-d422cf9d15ad7c411f6d51fac5299b895d8870af.tar.xz
slx-tools-d422cf9d15ad7c411f6d51fac5299b895d8870af.zip
[download] Increase default retry timeout, add --slx-time optionv29r2
-rw-r--r--modules/download.inc26
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"
}