Skip to content

Commit 008c21c

Browse files
committed
Auto merge of #115323 - onur-ozkan:curl-download-checksum-fix, r=Mark-Simulacrum
avoid stdout redirection on `curl` executions Avoid redirecting the curl output directly to the stdout. This alteration affects the integrity of the file during the retry process, as it also redirects the logs from the retries. Consequently, this leads to the bootstrap process failing because of an invalid checksum. For more information, see the [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/checksum.20errors) Fixes #115275
2 parents e51c5ea + 4ea90af commit 008c21c

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/bootstrap/bootstrap.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,15 @@ def _download(path, url, probably_big, verbose, exception):
104104
# If curl is not present on Win32, we should not sys.exit
105105
# but raise `CalledProcessError` or `OSError` instead
106106
require(["curl", "--version"], exception=platform_is_win32())
107-
with open(path, "wb") as outfile:
108-
run(["curl", option,
109-
"-L", # Follow redirect.
110-
"-y", "30", "-Y", "10", # timeout if speed is < 10 bytes/sec for > 30 seconds
111-
"--connect-timeout", "30", # timeout if cannot connect within 30 seconds
112-
"--retry", "3", "-SRf", url],
113-
stdout=outfile, #Implements cli redirect operator '>'
114-
verbose=verbose,
115-
exception=True, # Will raise RuntimeError on failure
116-
)
107+
run(["curl", option,
108+
"-L", # Follow redirect.
109+
"-y", "30", "-Y", "10", # timeout if speed is < 10 bytes/sec for > 30 seconds
110+
"--connect-timeout", "30", # timeout if cannot connect within 30 seconds
111+
"-o", path,
112+
"--retry", "3", "-SRf", url],
113+
verbose=verbose,
114+
exception=True, # Will raise RuntimeError on failure
115+
)
117116
except (subprocess.CalledProcessError, OSError, RuntimeError):
118117
# see http://serverfault.com/questions/301128/how-to-download
119118
if platform_is_win32():

src/bootstrap/download.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ impl Config {
225225
"10", // timeout if speed is < 10 bytes/sec for > 30 seconds
226226
"--connect-timeout",
227227
"30", // timeout if cannot connect within 30 seconds
228+
"-o",
229+
tempfile.to_str().unwrap(),
228230
"--retry",
229231
"3",
230232
"-SRf",
@@ -236,8 +238,6 @@ impl Config {
236238
curl.arg("--progress-bar");
237239
}
238240
curl.arg(url);
239-
let f = File::create(tempfile).unwrap();
240-
curl.stdout(Stdio::from(f));
241241
if !self.check_run(&mut curl) {
242242
if self.build.contains("windows-msvc") {
243243
eprintln!("Fallback to PowerShell");

0 commit comments

Comments
 (0)