-
Notifications
You must be signed in to change notification settings - Fork 125
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
Port to rustix, and add support for using Linux's renameat2
#166
Conversation
a9a5398
to
45388e6
Compare
@Stebalien any concerns delaying review on this PR? On a related note (due to the PR author), next month Rust 1.63 should have the new I/O Safety traits in Until it's acceptable to raise the MSRV to >=1.63 to use those traits directly from Lines 968 to 988 in 716e58e
tempfile/src/file/imp/windows.rs Lines 49 to 64 in 716e58e
@sunfishcode may offer to assist with that as they've expressed interest in contributing this improvement to popular crates, but it probably helps if their contribution efforts aren't left to stagnate without feedback? 😅 |
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.
Sorry, this fell off my radar. LGTM pending CI (which I'm trying to get to run now...).
This seems reasonable to me. Just make sure to ping me when it's ready for review. |
Port tempfile from libc to rustix. This simplifies error handling, string conversion, and factors out an `unsafe` block. This updates the MSRV to 1.48, which is rustix's MSRV.
Use `rustix::fs::renameat_with`, which corresponds to Linux's `renameat2`, to implement the non-overlapping form of `persist`, on Linux versions and filesystems where it's supported.
Co-authored-by: Brennan Kinney <[email protected]>
This ports tempfile to use the rustix crate instead of making direct libc calls, which factors out an
unsafe
block, simplifies error handling, and simplifies string handling.While here, it also implements a suggestion in a comment; on recent Linux it uses
renameat2
withRENAME_NOREPLACE
to implementpersist
in non-overwrite mode.This does require incrementing the minimum required Rust version to 1.48. Please feel free to decline this PR if you don't wish to take on these new requirements.