about summary refs log tree commit diff
path: root/src/bootstrap/bootstrap.py
diff options
context:
space:
mode:
authorbinarycat <binarycat@envs.net>2024-08-15 16:22:01 -0400
committerbinarycat <binarycat@envs.net>2024-08-16 19:30:20 -0400
commit12e638978814d84e4e09b172f784d5f16759d8e1 (patch)
tree3d92785981eb117fdcc236ba3075fd7fdd1ce161 /src/bootstrap/bootstrap.py
parent899eb03926be23f2e5d2ffcaa1d6f9ac40af7f13 (diff)
downloadrust-12e638978814d84e4e09b172f784d5f16759d8e1.tar.gz
rust-12e638978814d84e4e09b172f784d5f16759d8e1.zip
bootstrap: improve error recovery flags to curl
alternative to #128459

fixes #110178
Diffstat (limited to 'src/bootstrap/bootstrap.py')
-rw-r--r--src/bootstrap/bootstrap.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 4e8e0fd2532..5ea4b4882a9 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -79,6 +79,8 @@ def get(base, url, path, checksums, verbose=False):
                 eprint("removing", temp_path)
             os.unlink(temp_path)
 
+def curl_version():
+    return float(re.match(bytes("^curl ([0-9]+\\.[0-9]+)", "utf8"), require(["curl", "-V"]))[1])
 
 def download(path, url, probably_big, verbose):
     for _ in range(4):
@@ -107,11 +109,15 @@ def _download(path, url, probably_big, verbose, exception):
         # If curl is not present on Win32, we should not sys.exit
         #   but raise `CalledProcessError` or `OSError` instead
         require(["curl", "--version"], exception=platform_is_win32())
-        run(["curl", option,
+        extra_flags = []
+        if curl_version() > 7.70:
+            extra_flags = [ "--retry-all-errors" ]
+        run(["curl", option] + extra_flags + [
             "-L", # Follow redirect.
             "-y", "30", "-Y", "10",    # timeout if speed is < 10 bytes/sec for > 30 seconds
             "--connect-timeout", "30",  # timeout if cannot connect within 30 seconds
             "-o", path,
+            "--continue-at", "-",
             "--retry", "3", "-SRf", url],
             verbose=verbose,
             exception=True, # Will raise RuntimeError on failure