File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -376,7 +376,22 @@ where
376
376
}
377
377
378
378
pub fn remove_file ( name : & ' static str , path : & Path ) -> Result < ( ) > {
379
- fs:: remove_file ( path) . chain_err ( || ErrorKind :: RemovingFile {
379
+ // Most files we go to remove won't ever be in use. Some, like proxies, may
380
+ // be for indefinite periods, and this will mean we are slower to error and
381
+ // have the user fix the issue. Others, like the setup binary, are
382
+ // transiently in use, and this wait loop will fix the issue transparently
383
+ // for a rare performance hit.
384
+ retry (
385
+ Fibonacci :: from_millis ( 1 ) . map ( jitter) . take ( 10 ) ,
386
+ || match fs:: remove_file ( path) {
387
+ Ok ( ( ) ) => OperationResult :: Ok ( ( ) ) ,
388
+ Err ( e) => match e. kind ( ) {
389
+ io:: ErrorKind :: PermissionDenied => OperationResult :: Retry ( e) ,
390
+ _ => OperationResult :: Err ( e) ,
391
+ } ,
392
+ } ,
393
+ )
394
+ . chain_err ( || ErrorKind :: RemovingFile {
380
395
name,
381
396
path : PathBuf :: from ( path) ,
382
397
} )
You can’t perform that action at this time.
0 commit comments