-
Notifications
You must be signed in to change notification settings - Fork 0
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
add safe file writer #48
Conversation
* log warn if waiting to obtain the lock * retry renaming & log warn when 'finalizing' a safe write
* add func 'LockCount' to namedLocks
* add note
* discard previous implementation
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.
LGTM. This seems robust, even though I do think it could be a good idea to add randomness so that multiple temp files can exist concurrently, as this implementation could result in partial files if multiple writers use a safe writer, which isn't necessarily the best behavior.
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.
I am probably missing something, but where is the reader?
There's no specific reader: opening the file and reading from it gives the last successful version of it. |
Add safe file writing using implementation taken from https://github.com/google/renameio.
Given the potential performance impact, this implementation allows to by-pass the call to
fsync
.