@@ -7,8 +7,7 @@ mod tests;
7
7
use std:: path:: Path ;
8
8
9
9
use anyhow:: { anyhow, bail, Context , Result } ;
10
- use retry:: delay:: NoDelay ;
11
- use retry:: { retry, OperationResult } ;
10
+ use tokio_retry:: { strategy:: FixedInterval , RetryIf } ;
12
11
13
12
use crate :: currentprocess:: { process, varsource:: VarSource } ;
14
13
use crate :: dist:: component:: {
@@ -21,7 +20,7 @@ use crate::dist::manifest::{Component, CompressionKind, Manifest, TargetedPackag
21
20
use crate :: dist:: notifications:: * ;
22
21
use crate :: dist:: prefix:: InstallPrefix ;
23
22
use crate :: dist:: temp;
24
- use crate :: errors:: { OperationError , RustupError } ;
23
+ use crate :: errors:: RustupError ;
25
24
use crate :: utils:: utils;
26
25
27
26
pub ( crate ) const DIST_MANIFEST : & str = "multirust-channel-manifest.toml" ;
@@ -173,36 +172,22 @@ impl Manifestation {
173
172
174
173
let url_url = utils:: parse_url ( & url) ?;
175
174
176
- let downloaded_file =
177
- retry (
178
- NoDelay . take ( max_retries) ,
179
- || match crate :: utils:: utils:: run_future ( download_cfg. download ( & url_url, & hash) )
180
- {
181
- Ok ( f) => OperationResult :: Ok ( f) ,
182
- Err ( e) => {
183
- match e. downcast_ref :: < RustupError > ( ) {
184
- Some ( RustupError :: BrokenPartialFile ) => {
185
- ( download_cfg. notify_handler ) ( Notification :: RetryingDownload (
186
- & url,
187
- ) ) ;
188
- return OperationResult :: Retry ( OperationError ( e) ) ;
189
- }
190
- Some ( RustupError :: DownloadingFile { .. } ) => {
191
- ( download_cfg. notify_handler ) ( Notification :: RetryingDownload (
192
- & url,
193
- ) ) ;
194
- return OperationResult :: Retry ( OperationError ( e) ) ;
195
- }
196
- Some ( _) => return OperationResult :: Err ( OperationError ( e) ) ,
197
- None => ( ) ,
198
- } ;
199
- OperationResult :: Err ( OperationError ( e) )
175
+ let downloaded_file = utils:: run_future ( RetryIf :: spawn (
176
+ FixedInterval :: from_millis ( 0 ) . take ( max_retries) ,
177
+ || download_cfg. download ( & url_url, & hash) ,
178
+ |e : & anyhow:: Error | {
179
+ // retry only known retriable cases
180
+ match e. downcast_ref :: < RustupError > ( ) {
181
+ Some ( RustupError :: BrokenPartialFile )
182
+ | Some ( RustupError :: DownloadingFile { .. } ) => {
183
+ ( download_cfg. notify_handler ) ( Notification :: RetryingDownload ( & url) ) ;
184
+ true
200
185
}
201
- } ,
202
- )
203
- . with_context ( || {
204
- RustupError :: ComponentDownloadFailed ( component . name ( new_manifest ) )
205
- } ) ?;
186
+ _ => false ,
187
+ }
188
+ } ,
189
+ ) )
190
+ . with_context ( || RustupError :: ComponentDownloadFailed ( component . name ( new_manifest ) ) ) ?;
206
191
207
192
things_downloaded. push ( hash) ;
208
193
0 commit comments