Skip to content

Commit

Permalink
bootstrap: make wget use similar options to curl
Browse files Browse the repository at this point in the history
  • Loading branch information
lolbinarycat committed Aug 9, 2024
1 parent e7e3d38 commit 026da0b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,19 @@ def _download(path, url, probably_big, verbose, exception):

try:
if has_wget():
run(["wget", "--show-progress", "-O", path, url],
# options should be kept in sync with
# src/bootstrap/src/core/download.rs
# for consistancy
# these flags should also be as close as possible to the behavior
# of curl (except for wget's superior handling of surious network
# errors)
# curl's -R and -f are wget's default behavior.
run(["wget",
"--connect-timeout=30",
"--read-timeout=30",
"--tries=3",
"--show-progress",
"-O", path, url],
verbose=verbose,
exception=True,
)
Expand All @@ -121,6 +133,9 @@ def _download(path, url, probably_big, verbose, exception):
# timeout if cannot connect within 30 seconds
"--connect-timeout", "30",
"-o", path,
# -S: show errors, even if -s is specified
# -R: set timestamp of downloaded file to that of the server
# -f: fail on http error
"--retry", "3", "-SRf", url],
verbose=verbose,
exception=True, # Will raise RuntimeError on failure
Expand Down
10 changes: 9 additions & 1 deletion src/bootstrap/src/core/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,15 @@ impl Config {
"3",
"-SRf",
]);
wget.args(["-O", tempfile.to_str().unwrap()]);
// options should be kept in sync with
// src/bootstrap/bootstrap.py
// for consistancy
wget.args([
"--connect-timeout=30",
"--read-timeout=30",
"--tries=3",
"-O", tempfile.to_str().unwrap()
]);
// 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");
Expand Down

0 comments on commit 026da0b

Please sign in to comment.