From 95e555344dc746ad46ada9de9cc475042c63ec55 Mon Sep 17 00:00:00 2001 From: Bogdan Lukin Date: Thu, 30 Dec 2021 02:29:19 +0700 Subject: [PATCH] retry curl without `--continue-at -` flag (#95629) --- bin/internal/update_dart_sdk.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bin/internal/update_dart_sdk.sh b/bin/internal/update_dart_sdk.sh index 148f46c106..6f07d75997 100755 --- a/bin/internal/update_dart_sdk.sh +++ b/bin/internal/update_dart_sdk.sh @@ -116,6 +116,21 @@ if [ ! -f "$ENGINE_STAMP" ] || [ "$ENGINE_VERSION" != `cat "$ENGINE_STAMP"` ]; t fi curl ${verbose_curl} --retry 3 --continue-at - --location --output "$DART_SDK_ZIP" "$DART_SDK_URL" 2>&1 || { + curlExitCode=$? + # Handle range errors specially: retry again with disabled ranges (`--continue-at -` argument) + # When this could happen: + # - missing support of ranges in proxy servers + # - curl with broken handling of completed downloads + # This is not a proper fix, but doesn't require any user input + # - mirror of flutter storage without support of ranges + # + # 33 HTTP range error. The range "command" didn't work. + # https://man7.org/linux/man-pages/man1/curl.1.html#EXIT_CODES + if [ $curlExitCode != 33 ]; then + return $curlExitCode + fi + curl ${verbose_curl} --retry 3 --location --output "$DART_SDK_ZIP" "$DART_SDK_URL" 2>&1 + } || { >&2 echo >&2 echo "Failed to retrieve the Dart SDK from: $DART_SDK_URL" >&2 echo "If you're located in China, please see this page:"