From 98f9e276b032a139ef341a69e7967824718390bb Mon Sep 17 00:00:00 2001 From: Andrew Johnston Date: Sun, 4 Aug 2024 09:00:00 -0700 Subject: [PATCH] fix(build): retry webkit download on failure, resume download with curl (#13061) Co-authored-by: Andrew Johnston --- scripts/download-webkit.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/scripts/download-webkit.sh b/scripts/download-webkit.sh index 0595a12539..baac55be29 100755 --- a/scripts/download-webkit.sh +++ b/scripts/download-webkit.sh @@ -43,11 +43,34 @@ fi rm -rf "$OUTDIR" +download () { + local command="$1" + local retries="$2" + local options="$-" + if [[ $options == *e* ]]; then + set +e + fi + $command + local exit_code=$? + if [[ $options == *e* ]]; then + set -e + fi + if [[ $exit_code -ne 0 && $retries -gt 0 ]]; then + download "$command" $(($retries - 1)) + else + return $exit_code + fi +} + +# this is a big download so we will retry 5 times and ask curl to resume +# download from where failure occurred if it fails and is rerun if [ ! -f "$tar" ]; then echo "-- Downloading WebKit" - if ! curl -o "$tar" -L "$url"; then + if ! download "curl -C - --http1.1 -o $tar.tmp -L $url" 5; then echo "Failed to download $url" exit 1 + else + mv $tar.tmp $tar fi fi