Skip to content

Commit 4ea90af

Browse files
committed
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. Signed-off-by: onur-ozkan <[email protected]>
1 parent 18be272 commit 4ea90af

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
@@ -216,6 +216,8 @@ impl Config {
216216
"10", // timeout if speed is < 10 bytes/sec for > 30 seconds
217217
"--connect-timeout",
218218
"30", // timeout if cannot connect within 30 seconds
219+
"-o",
220+
tempfile.to_str().unwrap(),
219221
"--retry",
220222
"3",
221223
"-SRf",
@@ -227,8 +229,6 @@ impl Config {
227229
curl.arg("--progress-bar");
228230
}
229231
curl.arg(url);
230-
let f = File::create(tempfile).unwrap();
231-
curl.stdout(Stdio::from(f));
232232
if !self.check_run(&mut curl) {
233233
if self.build.contains("windows-msvc") {
234234
eprintln!("Fallback to PowerShell");

0 commit comments

Comments
 (0)