Skip to content

Commit b2644f0

Browse files
authored
Specify "origin private file system"-ness on a FileSystemHandle
Gives a FileSystemHandle an "is in an origin private file system" predicate which checks for the empty string in its path Better defining the OPFS itself (in terms of the Storage spec) is left to a follow-up Fixes #103
1 parent 2a7b613 commit b2644f0

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

index.bs

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ Each [=/file system locator=] has an associated <dfn export for="file system loc
241241
a <dfn export for="file system locator" id=locator-kind>kind</dfn> (a {{FileSystemHandleKind}}), and
242242
a <dfn export for="file system locator" id=locator-root>root</dfn> (a [=file system root=]).
243243

244-
Issue(103): Consider giving each locator a Storage Bucket.
244+
Issue(109): Consider giving each locator a [=storage bucket=].
245245

246246
A <dfn export>file locator</dfn> is a [=/file system locator=] whose
247247
[=file system locator/kind=] is {{FileSystemHandleKind/"file"}}.
@@ -341,6 +341,20 @@ A {{FileSystemHandle}} object is associated with a <dfn for=FileSystemHandle exp
341341
Note: Multiple {{FileSystemHandle}} objects can have
342342
[=the same locator as|the same=] [=/file system locator=].
343343

344+
A {{FileSystemHandle}}
345+
<dfn for=FileSystemHandle export>is in an origin private file system</dfn>
346+
if the first [=list/item=] of its [=FileSystemHandle/locator=]'s
347+
[=file system locator/path=] is the empty string.
348+
349+
Note: This is a bit magical, but it works since only the root directory of an
350+
[=origin private file system=] can have a [=file system locator/path=] which
351+
[=list/contains=] an empty string. See {{StorageManager/getDirectory()}}.
352+
All other [=list/item=]s of a [=file system locator/path=] will be a
353+
[=valid file name=].
354+
355+
Issue(109): Consider improving this situation by giving each locator a
356+
[=storage bucket=].
357+
344358
<div algorithm="serialization steps">
345359
{{FileSystemHandle}} objects are [=serializable objects=].
346360

@@ -594,8 +608,8 @@ The <dfn method for=FileSystemFileHandle>createWritable(|options|)</dfn> method
594608
The returned {{FileSystemSyncAccessHandle}} offers synchronous methods. This allows for higher performance
595609
on contexts where asynchronous operations come with high overhead, e.g., WebAssembly.
596610

597-
For the time being, this method will only succeed when the |fileHandle| belongs to the
598-
[=origin private file system=].
611+
For the time being, this method will only succeed when the |fileHandle|
612+
[=FileSystemHandle/is in an origin private file system=].
599613
</div>
600614

601615
<div algorithm>
@@ -605,6 +619,9 @@ The <dfn method for=FileSystemFileHandle>createSyncAccessHandle()</dfn> method s
605619
1. Let |locator| be [=this=]'s [=FileSystemHandle/locator=].
606620
1. Let |realm| be [=this=]'s [=relevant Realm=].
607621
1. Let |global| be [=this=]'s [=relevant global object=].
622+
1. Let |isInAnOriginPrivateFileSystem| be true if
623+
[=this=] [=FileSystemHandle/is in an origin private file system=];
624+
otherwise false.
608625
1. [=Enqueue the following steps=] to the [=file system queue=]:
609626
1. Let |entry| be the result of [=locating an entry=] given |locator|.
610627
1. Let |accessResult| be the result of running |entry|'s
@@ -615,15 +632,15 @@ The <dfn method for=FileSystemFileHandle>createSyncAccessHandle()</dfn> method s
615632
|accessResult|'s [=file system access result/error name=] and
616633
abort these steps.
617634

635+
1. If |isInAnOriginPrivateFileSystem| is false,
636+
[=queue a storage task=] with |global| to
637+
[=/reject=] |result| with an "{{InvalidStateError}}" {{DOMException}} and
638+
abort these steps.
639+
618640
1. If |entry| is `null`, [=queue a storage task=] with |global| to [=/reject=]
619641
|result| with a "{{NotFoundError}}" {{DOMException}} and abort these steps.
620642
1. [=Assert=]: |entry| is a [=file entry=].
621643

622-
1. If |entry| does not represent a [=/file system entry=] in an
623-
[=origin private file system=], [=queue a storage task=] with |global| to
624-
[=/reject=] |result| with an "{{InvalidStateError}}" {{DOMException}} and
625-
abort these steps.
626-
627644
1. Let |lockResult| be the result of [=file entry/lock/take|taking a lock=]
628645
with "`exclusive`" on |entry|.
629646

@@ -1653,7 +1670,7 @@ partial interface StorageManager {
16531670

16541671
<div class="note domintro">
16551672
: |directoryHandle| = await navigator . storage . {{StorageManager/getDirectory()}}
1656-
:: Returns the root directory of the origin private file system.
1673+
:: Returns the root directory of the [=origin private file system=].
16571674
</div>
16581675

16591676
<div algorithm>

0 commit comments

Comments
 (0)