-
Notifications
You must be signed in to change notification settings - Fork 139
Tempfile V4 #327
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
base: master
Are you sure you want to change the base?
Tempfile V4 #327
Conversation
5b4bec6 to
d2993fc
Compare
d85c389 to
1ca5737
Compare
1ca5737 to
ba0d77b
Compare
|
edit: nvm I missed that this actually attaches the path to the error. Didn't realize you could do that and still return a |
9011a9a to
2803c79
Compare
2803c79 to
37d51cd
Compare
569bcba to
2e6fbb3
Compare
Otherwise it's really easy to pass a temporary file handle by reference, causing it to be dropped by the receiver deleting the underlying file. fixes #115
1. Default to "tmp" as the file prefix instead of ".tmp". 2. Make it possible to construct the builder in a constfn. 3. Use a single lifetime in the builder.
That way, we can pass through additional builder options. This new struct implements AsRef<Path> and Deref<Target=Path> so breakage should be minimal.
Cursors are stable in rust as of 1.79. This change lets us keep a global scratch file behind a Mutex.
2e6fbb3 to
c9df86b
Compare
|
debian trixie has released with rust 1.85, though IIRC one of the other popular distro (centos or fedora, I can't remember) still on 1.84 |
Ah, that's good to know. I'll see if I can downgrade to that. Also note, I'm still planing on maintaining v3 for the foreseeable future. |
|
It's Ubuntu plucky. Which is unfortunately rules out 2024 edition unless I wait until October (although it might take that long anyways if I try to tackle the remaining TODOs). |
This is a stack of changes for tempfile v4. My plan is to wait for the next Debian stable release then set the MSRV to that, although I may merge and cut an RC before then. This version tries to be minimally breaking in "normal" code but it will still break some code (ideally code that was already broken/buggy).
Other than the MSRV bump (letting us drop
once_cell), changes include:AsRef<Path>on&NamedTempFile(and friends) instead of directly onNamedTempFile. That way, functions acceptingAsRef<Path>won't be able to take (then drop)NamedTempFileby value. See Got bitten by Drop impl running to early when passing TempDir to fn(p: impl AsRef<Path>) #115..by default. Temporary files shouldn't generally be hidden. Additionally, it's now possible to configure the default temporary-filename prefix via theenvpackage.Buildercan now has a single lifetime instead of separate ones forprefixandsuffix. It can also be constructed with a constBuilder::newif desired.Builder::makeused to take a&Pathbut now takes an&MakeParamsstruct (that dereferences to a&Path). This lets us pass additional builder parameters like the desired permissions.TempDir::into_pathis removed in favor ofTempDir::keep.SpooledTempDir::newis now const.tempfile::env::temp_dir()now returns a result and won't panic on platforms wherestd::env::temp_dirwould panic.TBD:
+t(sticky)? We can also make it configurable in the builder, the question will be: what's the default behavior?Fixes:
Builder(orcreate_helper) to check that the suppliedprefixandsuffixdon't contain/#59