Fallback to synchronous rm_dir call if path moving fails (#27306)

Remove some log lines, as suggested in PR #26910
This commit is contained in:
Xiang Zhu 2022-08-22 22:47:39 -07:00 committed by GitHub
parent 322fbc1406
commit 827d8e4bc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 10 deletions

View File

@ -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();
}