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 <work@onurozkan.dev>
This commit is contained in:
parent
18be2728bd
commit
4ea90af70f
@ -104,13 +104,12 @@ def _download(path, url, probably_big, verbose, exception):
|
|||||||
# If curl is not present on Win32, we should not sys.exit
|
# If curl is not present on Win32, we should not sys.exit
|
||||||
# but raise `CalledProcessError` or `OSError` instead
|
# but raise `CalledProcessError` or `OSError` instead
|
||||||
require(["curl", "--version"], exception=platform_is_win32())
|
require(["curl", "--version"], exception=platform_is_win32())
|
||||||
with open(path, "wb") as outfile:
|
|
||||||
run(["curl", option,
|
run(["curl", option,
|
||||||
"-L", # Follow redirect.
|
"-L", # Follow redirect.
|
||||||
"-y", "30", "-Y", "10", # timeout if speed is < 10 bytes/sec for > 30 seconds
|
"-y", "30", "-Y", "10", # timeout if speed is < 10 bytes/sec for > 30 seconds
|
||||||
"--connect-timeout", "30", # timeout if cannot connect within 30 seconds
|
"--connect-timeout", "30", # timeout if cannot connect within 30 seconds
|
||||||
|
"-o", path,
|
||||||
"--retry", "3", "-SRf", url],
|
"--retry", "3", "-SRf", url],
|
||||||
stdout=outfile, #Implements cli redirect operator '>'
|
|
||||||
verbose=verbose,
|
verbose=verbose,
|
||||||
exception=True, # Will raise RuntimeError on failure
|
exception=True, # Will raise RuntimeError on failure
|
||||||
)
|
)
|
||||||
|
@ -216,6 +216,8 @@ fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error:
|
|||||||
"10", // timeout if speed is < 10 bytes/sec for > 30 seconds
|
"10", // timeout if speed is < 10 bytes/sec for > 30 seconds
|
||||||
"--connect-timeout",
|
"--connect-timeout",
|
||||||
"30", // timeout if cannot connect within 30 seconds
|
"30", // timeout if cannot connect within 30 seconds
|
||||||
|
"-o",
|
||||||
|
tempfile.to_str().unwrap(),
|
||||||
"--retry",
|
"--retry",
|
||||||
"3",
|
"3",
|
||||||
"-SRf",
|
"-SRf",
|
||||||
@ -227,8 +229,6 @@ fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error:
|
|||||||
curl.arg("--progress-bar");
|
curl.arg("--progress-bar");
|
||||||
}
|
}
|
||||||
curl.arg(url);
|
curl.arg(url);
|
||||||
let f = File::create(tempfile).unwrap();
|
|
||||||
curl.stdout(Stdio::from(f));
|
|
||||||
if !self.check_run(&mut curl) {
|
if !self.check_run(&mut curl) {
|
||||||
if self.build.contains("windows-msvc") {
|
if self.build.contains("windows-msvc") {
|
||||||
eprintln!("Fallback to PowerShell");
|
eprintln!("Fallback to PowerShell");
|
||||||
|
Loading…
Reference in New Issue
Block a user