diff options
| author | Joshua Nelson <jnelson@cloudflare.com> | 2022-05-08 23:03:38 -0500 |
|---|---|---|
| committer | Joshua Nelson <jnelson@cloudflare.com> | 2022-05-25 17:32:31 -0500 |
| commit | 512d7bf874632c8ee133c0e6db382669344d3e48 (patch) | |
| tree | 8ffe4e65838048c41d5d3c5bb730ed8cd249666f | |
| parent | 23147273befa1312588d5ecc45d0316153125f04 (diff) | |
| download | rust-512d7bf874632c8ee133c0e6db382669344d3e48.tar.gz rust-512d7bf874632c8ee133c0e6db382669344d3e48.zip | |
Add support for UTF-8 paths to downloads in builder.rs
This is for a pre-existing FIXME, but it was easy enough to do.
| -rw-r--r-- | src/bootstrap/builder.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 45d649e78c8..b90a1d9d2a5 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -873,15 +873,15 @@ impl<'a> Builder<'a> { // Use a temporary file in case we crash while downloading, to avoid a corrupt download in cache/. let tempfile = self.tempdir().join(dest_path.file_name().unwrap()); // FIXME: support `do_verify` (only really needed for nightly rustfmt) - // FIXME: support non-utf8 paths? - self.download_with_retries(tempfile.to_str().unwrap(), &format!("{}/{}", base, url)); + self.download_with_retries(&tempfile, &format!("{}/{}", base, url)); t!(std::fs::rename(&tempfile, dest_path)); } - fn download_with_retries(&self, tempfile: &str, url: &str) { + fn download_with_retries(&self, tempfile: &Path, url: &str) { println!("downloading {}", url); // Try curl. If that fails and we are on windows, fallback to PowerShell. - if !self.check_run(Command::new("curl").args(&[ + let mut curl = Command::new("curl"); + curl.args(&[ "-#", "-y", "30", @@ -893,9 +893,10 @@ impl<'a> Builder<'a> { "3", "-Sf", "-o", - tempfile, - url, - ])) { + ]); + curl.arg(tempfile); + curl.arg(url); + if !self.check_run(&mut curl) { if self.build.build.contains("windows-msvc") { println!("Fallback to PowerShell"); for _ in 0..3 { @@ -905,7 +906,7 @@ impl<'a> Builder<'a> { "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;", &format!( "(New-Object System.Net.WebClient).DownloadFile('{}', '{}')", - url, tempfile + url, tempfile.to_str().expect("invalid UTF-8 not supported with powershell downloads"), ), ])) { return; |
