From ddc49783ce299ef182f883cabd39b11f5849b374 Mon Sep 17 00:00:00 2001 From: trevyn <230691+trevyn@users.noreply.github.com> Date: Sun, 28 May 2023 17:57:49 +0400 Subject: [PATCH] Fall back to `fs::remove_dir_all` on error --- crates/cargo-util/src/paths.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/cargo-util/src/paths.rs b/crates/cargo-util/src/paths.rs index 5e153de04..4c399d6a0 100644 --- a/crates/cargo-util/src/paths.rs +++ b/crates/cargo-util/src/paths.rs @@ -417,7 +417,10 @@ fn _create_dir_all(p: &Path) -> Result<()> { /// /// This does *not* follow symlinks. pub fn remove_dir_all>(p: P) -> Result<()> { - _remove_dir_all(p.as_ref()) + _remove_dir_all(p.as_ref()).or_else(|_| { + fs::remove_dir_all(p.as_ref()) + .with_context(|| format!("failed to remove directory `{}`", p.as_ref().display())) + }) } fn _remove_dir_all(p: &Path) -> Result<()> {