Skip to content

Commit af5af7c

Browse files
committed
Remove options parameter from constructor
In order to prevent caused compatibility issues with WebKit, the options parameter should be removed from create[Sync]AccessHandle(). For more context see whatwg/fs#19.
1 parent 27b0c28 commit af5af7c

File tree

1 file changed

+6
-41
lines changed

1 file changed

+6
-41
lines changed

AccessHandle.md

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
- [New data access surface](#new-data-access-surface)
2323
- [Locking semantics](#locking-semantics)
2424
- [Open Questions](#open-questions)
25-
- [Exposing AccessHandles on all filesystems](#exposing-accesshandles-on-all-filesystems)
2625
- [Assurances on non-awaited consistency](#assurances-on-non-awaited-consistency)
26+
- [Trying It Out](#trying-it-out)
2727
- [Appendix](#appendix)
2828
- [AccessHandle IDL](#accesshandle-idl)
2929
- [References & acknowledgements](#references--acknowledgements)
@@ -122,9 +122,7 @@ API](https://docs.google.com/document/d/1cOdnvuNIWWyJHz1uu8K_9DEgntMtedxfCzShI7d
122122

123123
```javascript
124124
// In all contexts
125-
// For details on the `mode` parameter see "Exposing AccessHandles on all
126-
// filesystems" below
127-
const accessHandle = await fileHandle.createAccessHandle({ mode: "in-place" });
125+
const accessHandle = await fileHandle.createAccessHandle();
128126
await accessHandle.writable.getWriter().write(buffer);
129127
const reader = accessHandle.readable.getReader({ mode: "byob" });
130128
// Assumes seekable streams, and SharedArrayBuffer support are available
@@ -158,9 +156,9 @@ default reader and writer with a *seek()* method.
158156
### Locking semantics
159157

160158
```javascript
161-
const accessHandle1 = await fileHandle.createAccessHandle({ mode: "in-place" });
159+
const accessHandle1 = await fileHandle.createAccessHandle();
162160
try {
163-
const accessHandle2 = await fileHandle.createAccessHandle({ mode: "in-place" });
161+
const accessHandle2 = await fileHandle.createAccessHandle();
164162
} catch (e) {
165163
// This catch will always be executed, since there is an open access handle
166164
}
@@ -184,31 +182,6 @@ observe changes done through the new API, even if a lock is still being held.
184182

185183
## Open Questions
186184

187-
### Exposing AccessHandles on all filesystems
188-
189-
This proposal only currently considers additions to OPFS, but it would probably
190-
be worthwhile to expand the new functionality to arbitrary file handles. While
191-
the exact behavior of *AccessHandles* outside of OPFS would need to be defined
192-
in detail, it's almost certain that the one described in this proposal should
193-
not be the default. To avoid setting it as such, we propose adding a required
194-
*mode* string parameter to *createAccessHandle()* and
195-
*createSyncAccessHandle()*. Some possible values *mode* could take are:
196-
197-
* 'shared': The current behavior seen in File System Access API in general,
198-
there is no locking and modifications are atomic (meaning that they would
199-
only actually change the file when the *AccessHandle* is closed). This mode
200-
would be a safe choice as a default value.
201-
* 'exclusive': An exclusive write lock is taken on the file, but modifications
202-
are still atomic. This is a useful mode for developers that want to
203-
coordinate various writing threads but still want "all or nothing" writes.
204-
* 'in-place': The behavior described in this proposal, allowing developers to
205-
use high performance access to files at the cost of not having atomic writes.
206-
It's possible that this mode would only be allowed in OPFS.
207-
208-
Both the naming and semantics of the *mode* parameter have to be more concretely
209-
defined. When a default behavior is agreed upon, the parameter should be made
210-
optional.
211-
212185
### Assurances on non-awaited consistency
213186

214187
It would be possible to clearly specify the behavior of an immediate async read
@@ -244,19 +217,11 @@ interface FileSystemFileHandle : FileSystemHandle {
244217
Promise<File> getFile();
245218
Promise<FileSystemWritableFileStream> createWritable(optional FileSystemCreateWritableOptions options = {});
246219
247-
Promise<FileSystemAccessHandle> createAccessHandle(FileSystemFileHandleCreateAccessHandleOptions options = {});
220+
Promise<FileSystemAccessHandle> createAccessHandle();
248221
[Exposed=DedicatedWorker]
249-
Promise<FileSystemSyncAccessHandle> createSyncAccessHandle(FileSystemFileHandleCreateAccessHandleOptions options = {});
250-
};
251-
252-
dictionary FileSystemFileHandleCreateAccessHandleOptions {
253-
required AccessHandleMode mode;
222+
Promise<FileSystemSyncAccessHandle> createSyncAccessHandle();
254223
};
255224
256-
// For more details and possible modes, see "Exposing AccessHandles on all
257-
// filesystems" above
258-
enum AccessHandleMode { "in-place" };
259-
260225
interface FileSystemAccessHandle {
261226
// Assumes seekable streams are available. The
262227
// Seekable extended attribute is ad-hoc notation for this proposal.

0 commit comments

Comments
 (0)