-
Notifications
You must be signed in to change notification settings - Fork 389
Ignore close errors in read-only files. #1130
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
Conversation
f2783db
to
aec2f31
Compare
src/shims/fs.rs
Outdated
// And return the result. | ||
result | ||
// We sync the file if it was opened in a mode different than read-only. | ||
if !handle.read_only { |
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.
Unless there are good arguments for the opposite, it's better to put the positive case first (if handle.read_only
). That avoids a mental double-negation when considering the else
branch.
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.
I did it this way to keep the "usual" behavior first and then be able to explain why the read-only exception is required.
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.
Why is read-write more "usual" than read-only?
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.
huh that's a good question. I don't think that's the case. Taking that into account, should I change the field inside the handle to read-write then?
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.
Whatever you prefer, as long as you avoid the negation here. ;)
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.
I changed it to avoid the double negation.
aec2f31
to
ce4e1f9
Compare
Looking good, thanks! @bors r+ |
📌 Commit a40a99d has been approved by |
☀️ Test successful - checks-travis, status-appveyor |
this fixes #999
r? @RalfJung