@@ -11,6 +11,7 @@ use futures_util::stream::StreamExt;
1111use std:: sync:: Arc ;
1212use tokio:: sync:: Semaphore ;
1313use tracing:: info;
14+ use url:: Url ;
1415
1516use crate :: dist:: component:: {
1617 Components , Package , PackageContext , TarGzPackage , TarXzPackage , TarZStdPackage , Transaction ,
@@ -187,7 +188,17 @@ impl Manifestation {
187188 let sem = semaphore. clone ( ) ;
188189 async move {
189190 let _permit = sem. acquire ( ) . await . unwrap ( ) ;
190- bin. download ( altered, tmp_cx, download_cfg, max_retries, new_manifest)
191+ let url = if altered {
192+ utils:: parse_url (
193+ & bin. binary
194+ . url
195+ . replace ( DEFAULT_DIST_SERVER , tmp_cx. dist_server . as_str ( ) ) ,
196+ ) ?
197+ } else {
198+ utils:: parse_url ( & bin. binary . url ) ?
199+ } ;
200+
201+ bin. download ( & url, download_cfg, max_retries, new_manifest)
191202 . await
192203 . map ( |downloaded| ( bin, downloaded) )
193204 }
@@ -745,33 +756,22 @@ struct ComponentBinary<'a> {
745756impl < ' a > ComponentBinary < ' a > {
746757 async fn download (
747758 & self ,
748- altered : bool ,
749- tmp_cx : & temp:: Context ,
759+ url : & Url ,
750760 download_cfg : & DownloadCfg < ' _ > ,
751761 max_retries : usize ,
752762 new_manifest : & Manifest ,
753763 ) -> Result < File > {
754764 use tokio_retry:: { RetryIf , strategy:: FixedInterval } ;
755765
756- let url = if altered {
757- self . binary
758- . url
759- . replace ( DEFAULT_DIST_SERVER , tmp_cx. dist_server . as_str ( ) )
760- } else {
761- self . binary . url . clone ( )
762- } ;
763-
764- let url_url = utils:: parse_url ( & url) ?;
765-
766766 let downloaded_file = RetryIf :: spawn (
767767 FixedInterval :: from_millis ( 0 ) . take ( max_retries) ,
768- || download_cfg. download ( & url_url , & self . binary . hash ) ,
768+ || download_cfg. download ( url , & self . binary . hash ) ,
769769 |e : & anyhow:: Error | {
770770 // retry only known retriable cases
771771 match e. downcast_ref :: < RustupError > ( ) {
772772 Some ( RustupError :: BrokenPartialFile )
773773 | Some ( RustupError :: DownloadingFile { .. } ) => {
774- ( download_cfg. notify_handler ) ( Notification :: RetryingDownload ( & url) ) ;
774+ ( download_cfg. notify_handler ) ( Notification :: RetryingDownload ( url. as_str ( ) ) ) ;
775775 true
776776 }
777777 _ => false ,
0 commit comments