Skip to content

feat(local): explicit close with error checking for LocalFileSystem#676

Open
jgiannuzzi wants to merge 1 commit intoapache:mainfrom
jgiannuzzi:explicit-close-with-error-reporting
Open

feat(local): explicit close with error checking for LocalFileSystem#676
jgiannuzzi wants to merge 1 commit intoapache:mainfrom
jgiannuzzi:explicit-close-with-error-reporting

Conversation

@jgiannuzzi
Copy link

Which issue does this PR close?

Implements one part of #661.

Rationale for this change

See issue. This PR is limited to explicitly calling close on written files with error checking.

What changes are included in this PR?

  • Add close_file() helper that calls libc::close() (Unix) / CloseHandle (Windows) directly and propagates errors, instead of relying on File::drop(). Note that this uses unsafe, like in the platforms' respective drop() implementations.
  • Apply both to the put and put_multipart (via LocalUpload) code paths.
  • Add libc (Unix) and windows-sys (Windows) as optional dependencies behind the fs feature for their respective platforms.
  • Add unit test verifying close_file detects EBADF when the file descriptor is closed behind Rust's back. This is just to validate that close_file properly 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.

Add explicit close with error checking on Unix (libc::close) and Windows
(CloseHandle), replacing silent drop.
@jgiannuzzi jgiannuzzi marked this pull request as ready for review March 23, 2026 13:07
@jgiannuzzi jgiannuzzi changed the title feat: explicit close with error checking for LocalFileSystem feat(local): explicit close with error checking for LocalFileSystem Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant