22
22
- [ New data access surface] ( #new-data-access-surface )
23
23
- [ Locking semantics] ( #locking-semantics )
24
24
- [ Open Questions] ( #open-questions )
25
- - [ Exposing AccessHandles on all filesystems] ( #exposing-accesshandles-on-all-filesystems )
26
25
- [ Assurances on non-awaited consistency] ( #assurances-on-non-awaited-consistency )
26
+ - [ Trying It Out] ( #trying-it-out )
27
27
- [ Appendix] ( #appendix )
28
28
- [ AccessHandle IDL] ( #accesshandle-idl )
29
29
- [ References & acknowledgements] ( #references--acknowledgements )
@@ -122,9 +122,7 @@ API](https://docs.google.com/document/d/1cOdnvuNIWWyJHz1uu8K_9DEgntMtedxfCzShI7d
122
122
123
123
``` javascript
124
124
// 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 ();
128
126
await accessHandle .writable .getWriter ().write (buffer);
129
127
const reader = accessHandle .readable .getReader ({ mode: " byob" });
130
128
// Assumes seekable streams, and SharedArrayBuffer support are available
@@ -158,9 +156,9 @@ default reader and writer with a *seek()* method.
158
156
### Locking semantics
159
157
160
158
``` javascript
161
- const accessHandle1 = await fileHandle .createAccessHandle ({ mode : " in-place " } );
159
+ const accessHandle1 = await fileHandle .createAccessHandle ();
162
160
try {
163
- const accessHandle2 = await fileHandle .createAccessHandle ({ mode : " in-place " } );
161
+ const accessHandle2 = await fileHandle .createAccessHandle ();
164
162
} catch (e) {
165
163
// This catch will always be executed, since there is an open access handle
166
164
}
@@ -184,31 +182,6 @@ observe changes done through the new API, even if a lock is still being held.
184
182
185
183
## Open Questions
186
184
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
-
212
185
### Assurances on non-awaited consistency
213
186
214
187
It would be possible to clearly specify the behavior of an immediate async read
@@ -244,19 +217,11 @@ interface FileSystemFileHandle : FileSystemHandle {
244
217
Promise<File> getFile();
245
218
Promise<FileSystemWritableFileStream> createWritable(optional FileSystemCreateWritableOptions options = {});
246
219
247
- Promise<FileSystemAccessHandle> createAccessHandle(FileSystemFileHandleCreateAccessHandleOptions options = {} );
220
+ Promise<FileSystemAccessHandle> createAccessHandle();
248
221
[Exposed=DedicatedWorker]
249
- Promise<FileSystemSyncAccessHandle> createSyncAccessHandle(FileSystemFileHandleCreateAccessHandleOptions options = {});
250
- };
251
-
252
- dictionary FileSystemFileHandleCreateAccessHandleOptions {
253
- required AccessHandleMode mode;
222
+ Promise<FileSystemSyncAccessHandle> createSyncAccessHandle();
254
223
};
255
224
256
- // For more details and possible modes, see "Exposing AccessHandles on all
257
- // filesystems" above
258
- enum AccessHandleMode { "in-place" };
259
-
260
225
interface FileSystemAccessHandle {
261
226
// Assumes seekable streams are available. The
262
227
// Seekable extended attribute is ad-hoc notation for this proposal.
0 commit comments