Skip to content

Commit

Permalink
bootstrap: pass long options to curl
Browse files Browse the repository at this point in the history
  • Loading branch information
lolbinarycat committed Sep 5, 2024
1 parent 44fac89 commit d513a22
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
12 changes: 6 additions & 6 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ def _download(path, url, probably_big, verbose, exception):

try:
if (probably_big or verbose) and "GITHUB_ACTIONS" not in os.environ:
option = "-#"
option = "--progress-bar"
else:
option = "-s"
option = "--silent"
# 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())
Expand All @@ -120,12 +120,12 @@ def _download(path, url, probably_big, verbose, exception):
# for consistency.
# they are also more compreprensivly explained in that file.
run(["curl", option] + extra_flags + [
"-L", # Follow redirect.
"-y", "30", "-Y", "10", # timeout if speed is < 10 bytes/sec for > 30 seconds
"--location", # Follow redirect.
"--speed-time", "30", "--speed-limit", "10", # timeout if speed is < 10 bytes/sec for > 30 seconds

Check failure on line 124 in src/bootstrap/bootstrap.py

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

line longer than 100 chars
"--connect-timeout", "30", # timeout if cannot connect within 30 seconds
"-o", path,
"--output", path,
"--continue-at", "-",
"--retry", "3", "-SRf", url],
"--retry", "3", "--show-error", "--remote-time", "--fail", url],
verbose=verbose,
exception=True, # Will raise RuntimeError on failure
)
Expand Down
20 changes: 11 additions & 9 deletions src/bootstrap/src/core/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,17 @@ impl Config {
let mut curl = command("curl");
curl.args([
// follow redirect
"-L",
"--location",
// timeout if speed is < 10 bytes/sec for > 30 seconds
"-y",
"--speed-time",
"30",
"-Y",
"--speed-limit",
"10",
// timeout if cannot connect within 30 seconds
"--connect-timeout",
"30",
// output file
"-o",
"--output",
tempfile.to_str().unwrap(),
// if there is an error, don't restart the download,
// instead continue where it left off.
Expand All @@ -253,14 +253,16 @@ impl Config {
// attempts will be made, since the first attempt isn't a *re*try.
"--retry",
"3",
// -S: show errors, even if -s is specified
// -R: set timestamp of downloaded file to that of the server
// -f: fail on non-ok http status
"-SRf",
// show errors, even if --silent is specified
"--show-error",
// set timestamp of downloaded file to that of the server
"--remote-time",
// fail on non-ok http status
"--fail",
]);
// Don't print progress in CI; the \r wrapping looks bad and downloads don't take long enough for progress to be useful.
if CiEnv::is_ci() {
curl.arg("-s");
curl.arg("--silent");
} else {
curl.arg("--progress-bar");
}
Expand Down

0 comments on commit d513a22

Please sign in to comment.