-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Observe close(2) errors for std::fs::{copy, write}
#149834
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
base: main
Are you sure you want to change the base?
Conversation
|
rustbot has assigned @Mark-Simulacrum. Use |
ab5eab8 to
38e2c5b
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
|
||
| io::copy(&mut reader, &mut writer) | ||
| let ret = io::copy(&mut reader, &mut writer)?; | ||
| writer.close()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though this can't fail, I copied it for symmetry with the other implementations.
This comment has been minimized.
This comment has been minimized.
38e2c5b to
cac4eb5
Compare
This comment has been minimized.
This comment has been minimized.
Adds a (private to `std`) `File::close` method and uses it in `std::fs::write` and `std::fs::copy`. This is a lighter version of rust-lang/libs-team#705 that can be added even if that ACP isn't accepted, as this is purely a quality of implementation thing that could be reverted at any time. External libraries and applications can use external crates like https://crates.io/crates/close-err to achieve the same with the files they own. CC rust-lang/libs-team#705.
cac4eb5 to
f7e0a04
Compare
|
So I don't see why these practically least-effort methods are the ones that would warrant extra care. Such a PR might be more appropriate to atomic write crates... except that they already do fsync, which subsumes this. |
|
We're just returning the error from |
|
Well, I both do not like the precedent, and I also think that if anything really needs to do this then these are the methods where it's the least necessary, which makes the first point worse "look, even these simple, least-defensive std methods do it!" |
Adds a (private to
std)File::closemethod and uses it instd::fs::writeandstd::fs::copy.This is a lighter version of rust-lang/libs-team#705 that can be added even if that ACP isn't accepted, as this is purely a quality of implementation thing that could be reverted at any time. External libraries and applications can use external crates like https://crates.io/crates/close-err to achieve the same with the files they own.
CC rust-lang/libs-team#705.