core: 下载重试间隔 5 秒

link #234
This commit is contained in:
bin456789 2025-01-13 22:39:38 +08:00
parent dd655a6db9
commit e2fb8484be
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B

View File

@ -99,10 +99,21 @@ is_have_cmd_on_disk() {
return 1
}
is_num() {
echo "$1" | grep -Exq '[0-9]*\.?[0-9]*'
}
retry() {
max_try=$1
local max_try=$1
shift
if is_num "$1"; then
local interval=$1
shift
else
local interval=5
fi
for i in $(seq $max_try); do
if "$@"; then
return
@ -111,7 +122,7 @@ retry() {
if [ $i -ge $max_try ]; then
return $ret
fi
sleep 1
sleep $interval
fi
done
}
@ -166,7 +177,7 @@ download() {
# --user-agent=Wget/1.21.1 \
echo "$url"
retry 5 stdbuf -oL -eL aria2c -x4 \
retry 5 5 stdbuf -oL -eL aria2c -x4 \
--allow-overwrite=true \
--summary-interval=0 \
--max-tries 1 \