Skip to content

Commit

Permalink
Fallback to synchronous rm_dir call if path moving fails (#27306)
Browse files Browse the repository at this point in the history
Remove some log lines, as suggested in PR #26910
  • Loading branch information
xiangzhu70 authored Aug 23, 2022
1 parent 322fbc1 commit 827d8e4
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2064,28 +2064,26 @@ fn move_and_async_delete_path(path: impl AsRef<Path> + Copy) {
));

if path_delete.exists() {
debug!("{} exists, delete it first.", path_delete.display());
std::fs::remove_dir_all(&path_delete).unwrap();
}

if !path.as_ref().exists() {
info!(
"move_and_async_delete_path: path {} does not exist",
path.as_ref().display()
);
return;
}

std::fs::rename(&path, &path_delete).unwrap();
if let Err(err) = std::fs::rename(&path, &path_delete) {
warn!(
"Path renaming failed: {}. Falling back to rm_dir in sync mode",
err.to_string()
);
std::fs::remove_dir_all(&path).unwrap();
return;
}

Builder::new()
.name("solDeletePath".to_string())
.spawn(move || {
std::fs::remove_dir_all(&path_delete).unwrap();
info!(
"Cleaning path {} done asynchronously in a spawned thread",
path_delete.display()
);
})
.unwrap();
}
Expand Down

0 comments on commit 827d8e4

Please sign in to comment.