Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Retry file deletion
  • Loading branch information
rbtcollins committed Jun 13, 2020
commit 2dffa4f9a0f118c69dc54bcfc83bcd70dd50f449
17 changes: 16 additions & 1 deletion src/utils/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,22 @@ where
}

pub fn remove_file(name: &'static str, path: &Path) -> Result<()> {
fs::remove_file(path).chain_err(|| ErrorKind::RemovingFile {
// Most files we go to remove won't ever be in use. Some, like proxies, may
// be for indefinite periods, and this will mean we are slower to error and
// have the user fix the issue. Others, like the setup binary, are
// transiently in use, and this wait loop will fix the issue transparently
// for a rare performance hit.
retry(
Fibonacci::from_millis(1).map(jitter).take(10),
|| match fs::remove_file(path) {
Ok(()) => OperationResult::Ok(()),
Err(e) => match e.kind() {
io::ErrorKind::PermissionDenied => OperationResult::Retry(e),
_ => OperationResult::Err(e),
},
},
)
.chain_err(|| ErrorKind::RemovingFile {
name,
path: PathBuf::from(path),
})
Expand Down