Skip to content

Commit 5b0ed02

Browse files
committed
Delete symlinked directories
1 parent e18c79a commit 5b0ed02

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/bootstrap/clean.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,14 @@ where
9999
// As a result, we have some special logic to remove readonly files on windows.
100100
// This is also the reason that we can't use things like fs::remove_dir_all().
101101
Err(ref e) if cfg!(windows) && e.kind() == ErrorKind::PermissionDenied => {
102-
let mut p = t!(path.symlink_metadata()).permissions();
102+
let m = t!(path.symlink_metadata());
103+
let mut p = m.permissions();
103104
p.set_readonly(false);
104105
t!(fs::set_permissions(path, p));
105106
f(path).unwrap_or_else(|e| {
106-
// Deleting symlinked directories on Windows is non-trivial.
107-
// Skip doing so for now.
107+
// Delete symlinked directories on Windows
108108
#[cfg(windows)]
109-
if e.kind() == ErrorKind::PermissionDenied && path.is_dir() {
110-
eprintln!("warning: failed to delete '{}'.", path.display());
109+
if m.file_type().is_symlink() && path.is_dir() && fs::remove_dir(path).is_ok() {
111110
return;
112111
}
113112
panic!("failed to {} {}: {}", desc, path.display(), e);

0 commit comments

Comments
 (0)