Skip to content

Commit

Permalink
Specify "origin private file system"-ness
Browse files Browse the repository at this point in the history
Fixes 103

Gives a FileSystemHandle an "is in an origin private file system"
predicate which checks for the empty string in its path
  • Loading branch information
a-sully committed Apr 6, 2023
1 parent 274a106 commit 2b149ba
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Each [=/file system locator=] has an associated <dfn export for="file system loc
a <dfn export for="file system locator" id=locator-kind>kind</dfn> (a {{FileSystemHandleKind}}), and
a <dfn export for="file system locator" id=locator-root>root</dfn> (a [=file system root=]).

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

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

A {{FileSystemHandle}}
<dfn for=FileSystemHandle export>is in an origin private file system</dfn>
if the first [=list/item=] of its [=FileSystemHandle/locator=]'s
[=file system locator/path=] is the empty string.

Note: This is a bit magical, but it works since only the root directory of an
[=origin private file system=] can have a [=file system locator/path=] which
[=list/contains=] an empty string. See {{StorageManager/getDirectory()}}.
All other [=list/item=]s of a [=file system locator/path=] will be a
[=valid file name=].

Issue(109): Consider improving this situation by giving each locator a
[=storage bucket=].

<div algorithm="serialization steps">
{{FileSystemHandle}} objects are [=serializable objects=].

Expand Down Expand Up @@ -535,15 +549,17 @@ The <dfn method for=FileSystemFileHandle>createWritable(|options|)</dfn> method
The returned {{FileSystemSyncAccessHandle}} offers synchronous methods. This allows for higher performance
on contexts where asynchronous operations come with high overhead, e.g., WebAssembly.

For the time being, this method will only succeed when the |fileHandle| belongs to the
[=origin private file system=].
For the time being, this method will only succeed when the |fileHandle|
[=FileSystemHandle/is in an origin private file system=].
</div>

<div algorithm>
The <dfn method for=FileSystemFileHandle>createSyncAccessHandle()</dfn> method steps are:

1. Let |result| be [=a new promise=].
1. Let |locator| be [=this=]'s [=FileSystemHandle/locator=].
1. Let |isInOriginPrivateFileSystem| be whether
[=this=] [=FileSystemHandle/is in an origin private file system=].
1. Run these steps [=in parallel=]:
1. Let |entry| be the result of [=locating an entry=] given |locator|.
1. Let |access| be the result of running |entry|'s
Expand All @@ -552,12 +568,13 @@ The <dfn method for=FileSystemFileHandle>createSyncAccessHandle()</dfn> method s
1. If |access| is not "{{PermissionState/granted}}",
[=reject=] |result| with a "{{NotAllowedError}}" {{DOMException}} and abort.

1. If |isInOriginPrivateFileSystem| is true, [=reject=] |result|
with an "{{InvalidStateError}}" {{DOMException}} and abort.

1. If |entry| is `null`, [=/reject=] |result| with a
"{{NotFoundError}}" {{DOMException}} and abort.
1. [=Assert=]: |entry| is a [=file entry=].

1. If |entry| does not represent a [=/file system entry=] in an [=origin private file system=],
[=reject=] |result| with an "{{InvalidStateError}}" {{DOMException}} and abort.
1. Let |lockResult| be the result of [=file entry/lock/take|taking a lock=] with "`exclusive`" on |entry|.
1. If |lockResult| is false, [=reject=] |result| with a "{{NoModificationAllowedError}}" {{DOMException}} and abort.
1. Let |handle| be the result of <a>creating a new `FileSystemSyncAccessHandle`</a>
Expand Down Expand Up @@ -1525,7 +1542,7 @@ partial interface StorageManager {

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

<div algorithm>
Expand Down

0 comments on commit 2b149ba

Please sign in to comment.