-
Notifications
You must be signed in to change notification settings - Fork 65
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 options to createWriter() to deal with atomic writes. #51
Conversation
index.bs
Outdated
This is typically implemented by writing data to a temporary file, and only replacing the file | ||
represented by |fileHandle| with the temporary file when the writer is closed. | ||
|
||
If |truncate| is `true` or not specified, the temporary file starts out empty, otherwise the |
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.
Instead of a flag, how about an enum?
fopen
provides the following options closest to what we want to achieve:
w
for truncate moder+
for read/write, with the cursor at the beginning of the file
I like the idea of update
to be the opposite of truncate
.
If we want to contrast with fopen
so there's no confusion, we can use slightly different enums:
enum FileSystemWriterMode {"truncate", "update"};
dictionary FileSystemCreateWriterOptions {
FileSystemWriterMode mode = "truncate";
boolean atomic = true;
};
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 went with victor's suggested names for now.
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.
FileSystemCreateWriterOptions is a great idea! Let's get that in.
I'd prefer that we discuss flush()
separately.
This attempts to solve #37 by making it explicit that changes made to files might not be reflected on disk until flush() or close() is called on the writer. This also introduces a "atomic" mode for FileSystemWriter where any changes are written to a temporary file, and only on flush or close is that file moved on top of the destination file. This should address #48.
eb26397
to
539edf6
Compare
This attempts to solve #37 by making it explicit that changes made to files
might not be reflected on disk until flush() or close() is called on the
writer.
This also introduces a "atomic" mode for FileSystemWriter where any changes
are written to a temporary file, and only on flush or close is that file
moved on top of the destination file. This should address #48.
Still to be decided if we actually want to implement the non-atomic mode at
first, as the semantics there aren't very clear. I.e. we might want to start with only
having an atomic mode.