diff options
author | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-07-21 10:00:26 +0800 |
---|---|---|
committer | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-07-21 10:00:26 +0800 |
commit | 978ddbae31a3769162cfb0fb1b6c95d96701d774 (patch) | |
tree | 7343bba8839bb00900c6b31ecfec7fae9e164a1a | |
parent | 8cdc2ea4decf7eceba3e01d67b64c41ab9ddcb26 (diff) |
Handle broken symlinks, they can now be deleted
These are tough, as metadata on them will fail, as it tries to follow
the symlink. It's odd, as we can still check if this was a symlink
in case it could be followed, but we can't check that in case it could
not be followed. In a way, the `metadata()` call should rather amended
with a sybling method like `nmetadata()` to have a version that doesn't
follow symlinks.
Anyway... .
-rw-r--r-- | src/interactive/app/handlers.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/interactive/app/handlers.rs b/src/interactive/app/handlers.rs index efff7dc..7f84809 100644 --- a/src/interactive/app/handlers.rs +++ b/src/interactive/app/handlers.rs @@ -300,10 +300,11 @@ fn delete_directory_recursively(path: PathBuf) -> Result<(), usize> { let mut dirs = Vec::new(); 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() .map(|m| m.file_type().is_symlink()) - .unwrap_or(false); + .unwrap_or(assume_symlink_to_try_deletion); if is_symlink { // do not follow symlinks num_errors += into_error_count(fs::remove_file(&path)); @@ -324,7 +325,7 @@ fn delete_directory_recursively(path: PathBuf) -> Result<(), usize> { num_errors += into_error_count(fs::remove_file(path)); continue; } - Err(_) => { + Err(e) => { num_errors += 1; continue; } |