@@ -873,15 +873,15 @@ impl<'a> Builder<'a> {
873873 // Use a temporary file in case we crash while downloading, to avoid a corrupt download in cache/.
874874 let tempfile = self . tempdir ( ) . join ( dest_path. file_name ( ) . unwrap ( ) ) ;
875875 // 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) ) ;
878877 t ! ( std:: fs:: rename( & tempfile, dest_path) ) ;
879878 }
880879
881- fn download_with_retries ( & self , tempfile : & str , url : & str ) {
880+ fn download_with_retries ( & self , tempfile : & Path , url : & str ) {
882881 println ! ( "downloading {}" , url) ;
883882 // 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 ( & [
885885 "-#" ,
886886 "-y" ,
887887 "30" ,
@@ -893,9 +893,10 @@ impl<'a> Builder<'a> {
893893 "3" ,
894894 "-Sf" ,
895895 "-o" ,
896- tempfile,
897- url,
898- ] ) ) {
896+ ] ) ;
897+ curl. arg ( tempfile) ;
898+ curl. arg ( url) ;
899+ if !self . check_run ( & mut curl) {
899900 if self . build . build . contains ( "windows-msvc" ) {
900901 println ! ( "Fallback to PowerShell" ) ;
901902 for _ in 0 ..3 {
@@ -905,7 +906,7 @@ impl<'a> Builder<'a> {
905906 "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;" ,
906907 & format ! (
907908 "(New-Object System.Net.WebClient).DownloadFile('{}', '{}')" ,
908- url, tempfile
909+ url, tempfile. to_str ( ) . expect ( "invalid UTF-8 not supported with powershell downloads" ) ,
909910 ) ,
910911 ] ) ) {
911912 return ;
0 commit comments