@@ -873,15 +873,15 @@ impl<'a> Builder<'a> {
873
873
// Use a temporary file in case we crash while downloading, to avoid a corrupt download in cache/.
874
874
let tempfile = self . tempdir ( ) . join ( dest_path. file_name ( ) . unwrap ( ) ) ;
875
875
// FIXME: support `do_verify` (only really needed for nightly rustfmt)
876
- // FIXME: support non-utf8 paths?
877
- self . download_with_retries ( tempfile. to_str ( ) . unwrap ( ) , & format ! ( "{}/{}" , base, url) ) ;
876
+ self . download_with_retries ( & tempfile, & format ! ( "{}/{}" , base, url) ) ;
878
877
t ! ( std:: fs:: rename( & tempfile, dest_path) ) ;
879
878
}
880
879
881
- fn download_with_retries ( & self , tempfile : & str , url : & str ) {
880
+ fn download_with_retries ( & self , tempfile : & Path , url : & str ) {
882
881
println ! ( "downloading {}" , url) ;
883
882
// Try curl. If that fails and we are on windows, fallback to PowerShell.
884
- if !self . check_run ( Command :: new ( "curl" ) . args ( & [
883
+ let mut curl = Command :: new ( "curl" ) ;
884
+ curl. args ( & [
885
885
"-#" ,
886
886
"-y" ,
887
887
"30" ,
@@ -893,9 +893,10 @@ impl<'a> Builder<'a> {
893
893
"3" ,
894
894
"-Sf" ,
895
895
"-o" ,
896
- tempfile,
897
- url,
898
- ] ) ) {
896
+ ] ) ;
897
+ curl. arg ( tempfile) ;
898
+ curl. arg ( url) ;
899
+ if !self . check_run ( & mut curl) {
899
900
if self . build . build . contains ( "windows-msvc" ) {
900
901
println ! ( "Fallback to PowerShell" ) ;
901
902
for _ in 0 ..3 {
@@ -905,7 +906,7 @@ impl<'a> Builder<'a> {
905
906
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;" ,
906
907
& format ! (
907
908
"(New-Object System.Net.WebClient).DownloadFile('{}', '{}')" ,
908
- url, tempfile
909
+ url, tempfile. to_str ( ) . expect ( "invalid UTF-8 not supported with powershell downloads" ) ,
909
910
) ,
910
911
] ) ) {
911
912
return ;
0 commit comments