Skip to content
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

Atomic File Write API #36664

Closed
simeonschaub opened this issue Jul 14, 2020 · 1 comment
Closed

Atomic File Write API #36664

simeonschaub opened this issue Jul 14, 2020 · 1 comment
Labels
duplicate Indicates similar issues or pull requests feature Indicates new feature / enhancement requests filesystem Underlying file system and functions that use it io Involving the I/O subsystem: libuv, read, write, etc.

Comments

@simeonschaub
Copy link
Member

From @StefanKarpinski on Slack:

Stefan Karpinski
one API we should arguably have is an “atomic write” API which writes to temp file that’s in the same directory as the ultimate output file and then replaces the destination file at the end if everything worked

Stefan Karpinski
in that case, you could just implement this with a normal open and “atomic” write

Stefan Karpinski
open_write_atomic seems very awkward

Stefan Karpinski
one possible API would be to add an atomic flag to open which changes the behavior of write to do that but you’d want it to mean something useful in other modes as well

Stefan Karpinski
in read mode it could mean move the file to a temp path first and then open it for read so that if someone writes to it, it doesn’t affect the read

I do believe that an API like this could be quite useful. I think Stefan also mentioned that this is already used in Pkg.

@vtjnash vtjnash changed the title Atomic Write API Atomic File Write API Jul 14, 2020
@StefanKarpinski StefanKarpinski added feature Indicates new feature / enhancement requests io Involving the I/O subsystem: libuv, read, write, etc. labels Jul 15, 2020
@vtjnash
Copy link
Member

vtjnash commented Oct 24, 2022

xref #39892

@LilithHafner LilithHafner added filesystem Underlying file system and functions that use it duplicate Indicates similar issues or pull requests labels Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Indicates similar issues or pull requests feature Indicates new feature / enhancement requests filesystem Underlying file system and functions that use it io Involving the I/O subsystem: libuv, read, write, etc.
Projects
None yet
Development

No branches or pull requests

4 participants