Skip to content

Commit

Permalink
Retry downloading dependency on failure up to 5 times
Browse files Browse the repository at this point in the history
  • Loading branch information
vit9696 committed Jul 4, 2019
1 parent 2d52025 commit 6ed8b29
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions Dependencies/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,24 @@ download_file() {
local url=$1
local file=$2

local ret=0
if [ $USE_CURL ]; then
curl -L "$url" -o "$dldir/$file" || ret=$?
else
wget "$url" -O "$dldir/$file" || ret=$?
fi
if (( $ret )); then
rm -f "$dldir/$file"
error_out "Failed to download %s" "$file"
fi
# Somtimes Travis CI networking starts to fail to resolve domains
# out of a sudden. Retry a few more times.
for n in {1..5}; do
local ret=0
if [ $USE_CURL ]; then
curl -L "$url" -o "$dldir/$file" || ret=$?
else
wget "$url" -O "$dldir/$file" || ret=$?
fi
if (( $ret )); then
rm -f "$dldir/$file"
warn "Failed to download %s, retrying" "$file"
sleep 1
else
return
fi
done
error_out "Failed to download %s" "$file"
}

# Fetch all of the things in the $sources[@] array. If they already exist
Expand Down

0 comments on commit 6ed8b29

Please sign in to comment.