Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 209eecf

Browse files
author
Sebastian Thiel
committed
Handle symlinks in a rather brutal way.
1 parent 854dc46 commit 209eecf

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/interactive/app/handlers.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ fn delete_directory_recursively(path: PathBuf) -> Result<(), usize> {
274274
}
275275
}
276276
Err(ref e) if e.kind() == io::ErrorKind::NotFound => {
277+
// it could also be a broken symlink
278+
num_errors += into_error_count(fs::remove_file(path));
277279
continue;
278280
}
279281
Err(ref e) if e.kind() == io::ErrorKind::Other => {
@@ -289,7 +291,7 @@ fn delete_directory_recursively(path: PathBuf) -> Result<(), usize> {
289291
}
290292

291293
for dir in dirs.into_iter().rev() {
292-
num_errors += into_error_count(fs::remove_dir(dir));
294+
num_errors += into_error_count(fs::remove_dir(&dir).or_else(|_| fs::remove_file(dir)));
293295
}
294296

295297
if num_errors == 0 {

0 commit comments

Comments
 (0)