termux_download.sh: simplify curl download error handling
Use curl built-in download retry mechanizm instead implementing such in shell loop.
This commit is contained in:
parent
5a4eedcd45
commit
8ecb74b324
|
@ -16,9 +16,7 @@ termux_download() {
|
|||
local TMPFILE
|
||||
TMPFILE=$(mktemp "$TERMUX_PKG_TMPDIR/download.$TERMUX_PKG_NAME.XXXXXXXXX")
|
||||
echo "Downloading ${URL}"
|
||||
local TRYMAX=6
|
||||
for try in $(seq 1 $TRYMAX); do
|
||||
if curl -L --fail --retry 2 -o "$TMPFILE" "$URL"; then
|
||||
if curl --fail --retry 10 --retry-connrefused --retry-delay 30 --location --output "$TMPFILE" "$URL"; then
|
||||
local ACTUAL_CHECKSUM
|
||||
ACTUAL_CHECKSUM=$(sha256sum "$TMPFILE" | cut -f 1 -d ' ')
|
||||
if [ "$CHECKSUM" != "SKIP_CHECKSUM" ]; then
|
||||
|
@ -33,11 +31,7 @@ termux_download() {
|
|||
fi
|
||||
mv "$TMPFILE" "$DESTINATION"
|
||||
return
|
||||
else
|
||||
echo "Download of $URL failed (attempt $try/$TRYMAX)" 1>&2
|
||||
sleep 45
|
||||
fi
|
||||
done
|
||||
|
||||
termux_error_exit "Failed to download $URL"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue