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

Add a autoClose flag to FileSystemCreateWritableOptions #86

Open
a-sully opened this issue Jan 9, 2023 · 0 comments
Open

Add a autoClose flag to FileSystemCreateWritableOptions #86

a-sully opened this issue Jan 9, 2023 · 0 comments
Labels
addition/proposal New features or enhancements

Comments

@a-sully
Copy link
Collaborator

a-sully commented Jan 9, 2023

This issue was initially posted in WICG/file-system-access#236, then migrated over to this spec as #19, which lumped the autoClose flag's proposal with some other proposals about file locking. Those file locking discussions are now taking place on #34, #19 has since been closed and this issue will track the autoClose feature in particular.

Here is the original description, pasted from WICG/file-system-access#236:

@mkruisselbrink

Currently you need to explicitly close a FileSystemWritableFileStream for the changes written to it to be flushed to disk. Usually this is a good thing, since it means that a website won't accidentally overwrite a file with a partial version of the file if for whatever reason the website is closed while it is writing to a file. I.e. changes are written to a temporary file and then atomically moved into place.

Sometimes websites to want to be able to write partial data to files though. For example in the case of an audio or video recorder it might be totally reasonable to just want to write however much data could be written, even if the app is closed unexpectedly.

To support that I propose adding a autoClose flag to FileSystemCreateWritableOptions. By default this is false, keeping the existing behavior. But if it is set to true, changes will be written to the target file even if the stream isn't explicitly closed (when the stream gets garbage collected/the page owning it gets closed). A website can still abort the write by calling abort() on the stream, and websites should still call close() to make sure the data gets moved into place as soon as feasible (relying on garbage collection would it make it very unpredictable when the changes show up on disk).

There is some overlap between this and earlier ideas for an "in-place" mode, but in-place mode makes things like safe browsing and other security checks much harder. So with no clear way forward for in-place, this will at least cover some of its use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements
Development

No branches or pull requests

2 participants