Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove is_empty(&dir) check from the rm::remove function #3

Open
ericcornelissen opened this issue Apr 25, 2023 · 0 comments
Open

Remove is_empty(&dir) check from the rm::remove function #3

ericcornelissen opened this issue Apr 25, 2023 · 0 comments
Labels
enhancement New feature or request pending This cannot be worked on yet

Comments

@ericcornelissen
Copy link
Owner

Feature Improvement

Summary

the rm::remove function currently has a custom time-of-check-time-of-use condition for non-empty directories:

rust-rm/src/main.rs

Lines 2598 to 2604 in 155b391

if entry.is_dir() && !fs::is_empty(&entry) {
// This case is handled explicitly because, as of Rust 1.69, the `io::ErrorKind` variant
// is still experimental (gate "io_error_more") and so would result in an unknown error.
// This implementation leaves a possibility for a TOCTOU issue, but this will be handled
// safely as `std::fs::remove_dir` doesn't remove non-empty directories.
return Err(entry.into_err(fs::ErrorKind::DirectoryNotEmpty));
}

Per the comment, this exists to provide a context relevant error (instead of "Unknown error") in most cases.

Once the io_error_more feature gate is resolved, this explicit check can and should be removed (assuming it lands ErrorKind::DirectoryNotEmpty).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pending This cannot be worked on yet
Projects
None yet
Development

No branches or pull requests

1 participant