@@ -11,6 +11,7 @@ use futures_util::stream::StreamExt;
11
11
use std:: sync:: Arc ;
12
12
use tokio:: sync:: Semaphore ;
13
13
use tracing:: info;
14
+ use url:: Url ;
14
15
15
16
use crate :: dist:: component:: {
16
17
Components , Package , PackageContext , TarGzPackage , TarXzPackage , TarZStdPackage , Transaction ,
@@ -187,7 +188,17 @@ impl Manifestation {
187
188
let sem = semaphore. clone ( ) ;
188
189
async move {
189
190
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)
191
202
. await
192
203
. map ( |downloaded| ( bin, downloaded) )
193
204
}
@@ -745,33 +756,22 @@ struct ComponentBinary<'a> {
745
756
impl < ' a > ComponentBinary < ' a > {
746
757
async fn download (
747
758
& self ,
748
- altered : bool ,
749
- tmp_cx : & temp:: Context ,
759
+ url : & Url ,
750
760
download_cfg : & DownloadCfg < ' _ > ,
751
761
max_retries : usize ,
752
762
new_manifest : & Manifest ,
753
763
) -> Result < File > {
754
764
use tokio_retry:: { RetryIf , strategy:: FixedInterval } ;
755
765
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
-
766
766
let downloaded_file = RetryIf :: spawn (
767
767
FixedInterval :: from_millis ( 0 ) . take ( max_retries) ,
768
- || download_cfg. download ( & url_url , & self . binary . hash ) ,
768
+ || download_cfg. download ( url , & self . binary . hash ) ,
769
769
|e : & anyhow:: Error | {
770
770
// retry only known retriable cases
771
771
match e. downcast_ref :: < RustupError > ( ) {
772
772
Some ( RustupError :: BrokenPartialFile )
773
773
| Some ( RustupError :: DownloadingFile { .. } ) => {
774
- ( download_cfg. notify_handler ) ( Notification :: RetryingDownload ( & url) ) ;
774
+ ( download_cfg. notify_handler ) ( Notification :: RetryingDownload ( url. as_str ( ) ) ) ;
775
775
true
776
776
}
777
777
_ => false ,
0 commit comments