Skip to content

build_helper: Exponentially increase rm delay #140114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
4 changes: 2 additions & 2 deletions src/build_helper/src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn recursive_remove<P: AsRef<Path>>(path: P) -> io::Result<()> {
let is_dir_like = fs::Metadata::is_dir;

const MAX_RETRIES: usize = 5;
const RETRY_DELAY_MS: u64 = 100;
const RETRY_MIN_DELAY_MS: u64 = 100;

let try_remove = || {
if is_dir_like(&metadata) {
Expand All @@ -72,7 +72,7 @@ pub fn recursive_remove<P: AsRef<Path>>(path: P) -> io::Result<()> {
Ok(()) => return Ok(()),
Err(e) if e.kind() == io::ErrorKind::NotFound => return Ok(()),
Err(_) if attempt < MAX_RETRIES - 1 => {
std::thread::sleep(std::time::Duration::from_millis(RETRY_DELAY_MS));
std::thread::sleep(std::time::Duration::from_millis(RETRY_MIN_DELAY_MS << attempt));
continue;
}
Err(e) => return Err(e),
Expand Down
Loading