crepererum commented on code in PR #676:
URL:
https://github.com/apache/arrow-rs-object-store/pull/676#discussion_r3046529686
##########
src/local.rs:
##########
@@ -137,6 +137,37 @@ impl From<Error> for super::Error {
}
}
+/// Explicitly close a file, checking for errors that would be silently
ignored by Rust's `File::drop()`.
+///
+/// On network filesystems (e.g. NFS), `close()` can fail and indicate data
loss.
+fn close_file(file: File) -> std::result::Result<(), io::Error> {
+ #[cfg(target_family = "unix")]
+ {
+ use std::os::unix::io::IntoRawFd;
+ let fd = file.into_raw_fd();
+ // SAFETY: `fd` is a valid, owned file descriptor obtained from
`into_raw_fd()`.
+ match unsafe { libc::close(fd) } {
+ 0 => Ok(()),
+ _ => Err(io::Error::last_os_error()),
+ }
Review Comment:
I think `nix` is a fine choice here and keeps the dev and prod world kinda
in-sync :+1:
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]