summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinzent Steinberg <Vinzent.Steinberg@gmail.com>2019-07-25 12:41:50 +0200
committerSebastian Thiel <sthiel@thoughtworks.com>2019-07-26 10:26:32 +0800
commite01f157d708eb1cf5cdef0daff843eda98c5db76 (patch)
tree2ffd74f80899e0b195d15ac352f9e65cdf2781a0
parent4e500beb8444f6d9fa31ab984551716fb480d7f5 (diff)
Don't follow symlinks when deleting files recursively
The fix in 560a76d43fa44c4ebf9bdc51087647bb800bbe68 did not work, because it checked the metadata of the file the symlink was pointing to, instead of the metadata of the symlink. Effectively, this resulted in symlinks never being detected. Also see https://doc.rust-lang.org/std/fs/struct.FileType.html#method.is_symlink. Fixes #24.
-rw-r--r--src/interactive/app/handlers.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/interactive/app/handlers.rs b/src/interactive/app/handlers.rs
index 843b186..96dddb7 100644
--- a/src/interactive/app/handlers.rs
+++ b/src/interactive/app/handlers.rs
@@ -307,8 +307,7 @@ fn delete_directory_recursively(path: PathBuf) -> Result<(), usize> {
let mut num_errors = 0;
while let Some(path) = files_or_dirs.pop() {
let assume_symlink_to_try_deletion = true;
- let is_symlink = path
- .metadata()
+ let is_symlink = path.symlink_metadata()
.map(|m| m.file_type().is_symlink())
.unwrap_or(assume_symlink_to_try_deletion);
if is_symlink {