Skip to content

Commit

Permalink
Fix deletion process on Rust 1.55
Browse files Browse the repository at this point in the history
Rust 1.55 unfortunately breaks the existing code which assumed that
ErrorKind::Other will be returned by fs::read_dir() when a file is
encountered. For now just always try deleting as if it's a file with the
possibility to add the optimization back again once the `io_error_more`
feature is stabilized.

References:
- https://blog.rust-lang.org/2021/09/09/Rust-1.55.0.html#stdioerrorkind-variants-updated
- rust-lang/rust#85746
- rust-lang/rust#86442
  • Loading branch information
Bobo1239 committed Sep 17, 2021
1 parent c148b77 commit f55adf3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/interactive/app/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,15 @@ fn delete_directory_recursively(path: PathBuf) -> Result<(), usize> {
}
}
}
Err(ref e) if e.kind() == io::ErrorKind::Other => {
// assume file, save IOps
num_errors += into_error_count(fs::remove_file(path));
continue;
}
// Err(ref e) if e.kind() == io::ErrorKind::NotADirectory => {
// // assume file, save IOps
// num_errors += into_error_count(fs::remove_file(path));
// continue;
// }
Err(_) => {
num_errors += 1;
// TODO: Reintroduce commented code once the `io_error_more` feature is stable
// num_errors += 1;
num_errors += into_error_count(fs::remove_file(path));
continue;
}
};
Expand Down

0 comments on commit f55adf3

Please sign in to comment.