From 827d8e4bc0c25966b86784b8589faede838a762f Mon Sep 17 00:00:00 2001 From: Xiang Zhu Date: Mon, 22 Aug 2022 22:47:39 -0700 Subject: [PATCH] Fallback to synchronous rm_dir call if path moving fails (#27306) Remove some log lines, as suggested in PR #26910 --- core/src/validator.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/core/src/validator.rs b/core/src/validator.rs index babc1e1fb2..c271e0aa17 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -2064,28 +2064,26 @@ fn move_and_async_delete_path(path: impl AsRef + 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(); }