about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRyan Levick <me@ryanlevick.com>2021-02-16 17:08:11 +0100
committerRyan Levick <me@ryanlevick.com>2021-02-16 21:19:53 +0100
commit5b0ed02bb9e0ee00c32cbf41eb2a12fe5476fe56 (patch)
tree8bb06cb81a9f43bafc1e56e20745c1d5486b76a1
parente18c79a4a9c06ae8dc282f1b4aae560a3076d9cd (diff)
downloadrust-5b0ed02bb9e0ee00c32cbf41eb2a12fe5476fe56.tar.gz
rust-5b0ed02bb9e0ee00c32cbf41eb2a12fe5476fe56.zip
Delete symlinked directories
-rw-r--r--src/bootstrap/clean.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/bootstrap/clean.rs b/src/bootstrap/clean.rs
index c2f01ecfd1f..3216c1af267 100644
--- a/src/bootstrap/clean.rs
+++ b/src/bootstrap/clean.rs
@@ -99,15 +99,14 @@ where
         // As a result, we have some special logic to remove readonly files on windows.
         // This is also the reason that we can't use things like fs::remove_dir_all().
         Err(ref e) if cfg!(windows) && e.kind() == ErrorKind::PermissionDenied => {
-            let mut p = t!(path.symlink_metadata()).permissions();
+            let m = t!(path.symlink_metadata());
+            let mut p = m.permissions();
             p.set_readonly(false);
             t!(fs::set_permissions(path, p));
             f(path).unwrap_or_else(|e| {
-                // Deleting symlinked directories on Windows is non-trivial.
-                // Skip doing so for now.
+                // Delete symlinked directories on Windows
                 #[cfg(windows)]
-                if e.kind() == ErrorKind::PermissionDenied && path.is_dir() {
-                    eprintln!("warning: failed to delete '{}'.", path.display());
+                if m.file_type().is_symlink() && path.is_dir() && fs::remove_dir(path).is_ok() {
                     return;
                 }
                 panic!("failed to {} {}: {}", desc, path.display(), e);