[macOS] Rework retry helper function (#1871)
* Rework macOS retry helper * Add more logs
This commit is contained in:
@@ -5,22 +5,31 @@ download_with_retries() {
|
|||||||
local URL="$1"
|
local URL="$1"
|
||||||
local DEST="${2:-.}"
|
local DEST="${2:-.}"
|
||||||
local NAME="${3:-${URL##*/}}"
|
local NAME="${3:-${URL##*/}}"
|
||||||
|
local COMPRESSED="$4"
|
||||||
|
|
||||||
echo "Downloading $URL..."
|
if [[ $COMPRESSED == "compressed" ]]; then
|
||||||
wget $URL --output-document="$DEST/$NAME" \
|
COMMAND="curl $URL -4 -sL --compressed -o '$DEST/$NAME'"
|
||||||
--tries=30 \
|
else
|
||||||
--wait 30 \
|
COMMAND="curl $URL -4 -sL -o '$DEST/$NAME'"
|
||||||
--retry-connrefused \
|
|
||||||
--retry-on-host-error \
|
|
||||||
--retry-on-http-error=404,429,500,502,503 \
|
|
||||||
--no-verbose
|
|
||||||
|
|
||||||
if [ $? != 0 ]; then
|
|
||||||
echo "Could not download $URL; Exiting build!"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
echo "Downloading $URL..."
|
||||||
|
retries=20
|
||||||
|
interval=30
|
||||||
|
while [ $retries -gt 0 ]; do
|
||||||
|
((retries--))
|
||||||
|
eval $COMMAND
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
echo "Unable to download $URL, next attempt in $interval sec, $retries attempts left"
|
||||||
|
sleep $interval
|
||||||
|
else
|
||||||
|
echo "$URL was downloaded successfully to $DEST/$NAME"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Could not download $URL"
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
is_BigSur() {
|
is_BigSur() {
|
||||||
|
|||||||
Reference in New Issue
Block a user