-
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
Recipe for non clobbering atomic persist? #333
Comments
Stebalien
added a commit
that referenced
this issue
Feb 21, 2025
It's "atomic" on modern Linux (assuming a modern filesystem, etc.) and on Windows, but not on macos or the various BSDs (or anything else). By "not atomic", I mean that the old name for the temporary file might persist in the filesystem (the rename isn't atomic). Any files at the target path will never be overwritten. Does #334 help clarify this? |
Yep! That clarifies it. Thank you. |
Stebalien
added a commit
that referenced
this issue
Feb 21, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NamedTempFile
has two methods for persisting,persist()
andpersist_noclobber()
. The former is atomic while the latter is not as stated by the documentation.Now I'm no expert here, which is why I'm grateful for this crate so thank you for your work, but I was wondering how would I go about achieving non clobbering atomic persist? A naive implementation would look like the following pseudocode:
But I'm guessing that the above is susceptible to race conditions.
If the answer is that
persist_noclobber
is already the best that's possible, then that's okay too. Feel free to close this issue in that case.The text was updated successfully, but these errors were encountered: