feat(local): explicit close with error checking for LocalFileSystem#676
Open
jgiannuzzi wants to merge 1 commit intoapache:mainfrom
Open
feat(local): explicit close with error checking for LocalFileSystem#676jgiannuzzi wants to merge 1 commit intoapache:mainfrom
jgiannuzzi wants to merge 1 commit intoapache:mainfrom
Conversation
Add explicit close with error checking on Unix (libc::close) and Windows (CloseHandle), replacing silent drop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Implements one part of #661.
Rationale for this change
See issue. This PR is limited to explicitly calling
closeon written files with error checking.What changes are included in this PR?
close_file()helper that callslibc::close()(Unix) /CloseHandle(Windows) directly and propagates errors, instead of relying onFile::drop(). Note that this usesunsafe, like in the platforms' respectivedrop()implementations.putandput_multipart(viaLocalUpload) code paths.libc(Unix) andwindows-sys(Windows) as optional dependencies behind thefsfeature for their respective platforms.close_filedetectsEBADFwhen the file descriptor is closed behind Rust's back. This is just to validate thatclose_fileproperly returns the OS error.Are there any user-facing changes?
Close errors are now detected and propagated as
Error::UnableToCopyDataToFile. Previously these were silently ignored. This is a correctness improvement but could surface errors that were previously hidden.