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
|
local TMPFILE
|
||||||
TMPFILE=$(mktemp "$TERMUX_PKG_TMPDIR/download.$TERMUX_PKG_NAME.XXXXXXXXX")
|
TMPFILE=$(mktemp "$TERMUX_PKG_TMPDIR/download.$TERMUX_PKG_NAME.XXXXXXXXX")
|
||||||
echo "Downloading ${URL}"
|
echo "Downloading ${URL}"
|
||||||
local TRYMAX=6
|
if curl --fail --retry 10 --retry-connrefused --retry-delay 30 --location --output "$TMPFILE" "$URL"; then
|
||||||
for try in $(seq 1 $TRYMAX); do
|
|
||||||
if curl -L --fail --retry 2 -o "$TMPFILE" "$URL"; then
|
|
||||||
local ACTUAL_CHECKSUM
|
local ACTUAL_CHECKSUM
|
||||||
ACTUAL_CHECKSUM=$(sha256sum "$TMPFILE" | cut -f 1 -d ' ')
|
ACTUAL_CHECKSUM=$(sha256sum "$TMPFILE" | cut -f 1 -d ' ')
|
||||||
if [ "$CHECKSUM" != "SKIP_CHECKSUM" ]; then
|
if [ "$CHECKSUM" != "SKIP_CHECKSUM" ]; then
|
||||||
@ -33,11 +31,7 @@ termux_download() {
|
|||||||
fi
|
fi
|
||||||
mv "$TMPFILE" "$DESTINATION"
|
mv "$TMPFILE" "$DESTINATION"
|
||||||
return
|
return
|
||||||
else
|
|
||||||
echo "Download of $URL failed (attempt $try/$TRYMAX)" 1>&2
|
|
||||||
sleep 45
|
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
|
||||||
termux_error_exit "Failed to download $URL"
|
termux_error_exit "Failed to download $URL"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user