Skip to content

Commit 9c645b0

Browse files
author
Nathan Memmott
committed
Support locking of directory entries
Moves the locking algorithm from file entry to file system entry. Fixes whatwg#137
1 parent fad217a commit 9c645b0

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

index.bs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ result of [=starting a new parallel queue=]. This queue is to be used for all
130130
file sytem operations.
131131

132132
<div algorithm>
133-
To <dfn for="file system entry/lock">take</dfn> a [=file system entry/lock=] with a |value| of
133+
To <dfn for="file system entry/lock">take a lock</dfn> with a |value| of
134134
"`exclusive`" or "`shared`" on a given [=/file system entry=] |entry|:
135135

136136
1. Let |lock| be the |entry|'s [=file system entry/lock=].
137137
1. Let |count| be the |entry|'s [=file system entry/shared lock count=].
138-
1. Let |hasDescendantLock| be the result of [=file system entry/lock/checking for a descendant lock=] on |entry|.
139-
1. If |hasDescendantLock| is true:
138+
1. Let |descendantLockStatus| be the result of [=file system entry/lock/checking for a descendant lock=] on |entry|.
139+
1. If |descendantLockStatus| is "`taken`":
140140
1. Return "`failure`".
141141
1. If |value| is "`exclusive`":
142142
1. If |lock| is "`open`":
@@ -162,13 +162,13 @@ To <dfn for="file system entry/lock">check for a descendant lock</dfn> on a give
162162

163163
1. Let |lock| be the |entry|'s [=file system entry/lock=].
164164
1. If |lock| is not "`open`":
165-
1. Return true.
165+
1. Return "`taken`".
166166
1. If |entry| is a [=directory entry=]:
167167
1. [=set/For each=] |child| of |entry|'s [=directory entry/children=]:
168-
1. Let |hasDescendantLock| be the result of [=file system entry/lock/checking for a descendant lock=] on |child|.
169-
1. If |hasDescendantLock| is true:
170-
1. Return true.
171-
1. Return false.
168+
1. Let |descendantLockStatus| be the result of [=file system entry/lock/checking for a descendant lock=] on |child|.
169+
1. If |descendantLockStatus| is "`taken`":
170+
1. Return "`taken`".
171+
1. Return "`open`".
172172

173173
Note: These steps have to be run on the [=file system queue=].
174174

@@ -558,7 +558,7 @@ The <dfn method for=FileSystemFileHandle>getFile()</dfn> method steps are:
558558
the temporary file starts out empty,
559559
otherwise the existing file is first copied to this temporary file.
560560

561-
Creating a {{FileSystemWritableFileStream}} [=file system entry/lock/take|takes a shared lock=] on the
561+
Creating a {{FileSystemWritableFileStream}} [=file system entry/lock/take a lock|takes a shared lock=] on the
562562
[=file entry=] [=locate an entry|locatable=] with |fileHandle|'s [=FileSystemHandle/locator=].
563563
This prevents the creation of {{FileSystemSyncAccessHandle|FileSystemSyncAccessHandles}}
564564
for the entry, until the stream is closed.
@@ -595,7 +595,7 @@ The <dfn method for=FileSystemFileHandle>createWritable(|options|)</dfn> method
595595
|result| with a "{{NotFoundError}}" {{DOMException}} and abort these steps.
596596
1. [=Assert=]: |entry| is a [=file entry=].
597597

598-
1. Let |lockResult| be the result of [=file system entry/lock/take|taking a lock=]
598+
1. Let |lockResult| be the result of [=file system entry/lock/take a lock|taking a lock=]
599599
with "`shared`" on |entry|.
600600

601601
1. [=Queue a storage task=] with |global| to run these steps:
@@ -623,7 +623,7 @@ The <dfn method for=FileSystemFileHandle>createWritable(|options|)</dfn> method
623623
[=file entry=] [=locate an entry|locatable=] by |fileHandle|'s [=FileSystemHandle/locator=].
624624
To ensure the changes are reflected in this file, the handle can be flushed.
625625

626-
Creating a {{FileSystemSyncAccessHandle}} [=file system entry/lock/take|takes an exclusive lock=] on the
626+
Creating a {{FileSystemSyncAccessHandle}} [=file system entry/lock/take a lock|takes an exclusive lock=] on the
627627
[=file entry=] [=locate an entry|locatable=] with |fileHandle|'s [=FileSystemHandle/locator=].
628628
This prevents the creation of further {{FileSystemSyncAccessHandle|FileSystemSyncAccessHandles}}
629629
or {{FileSystemWritableFileStream|FileSystemWritableFileStreams}}
@@ -665,7 +665,7 @@ The <dfn method for=FileSystemFileHandle>createSyncAccessHandle()</dfn> method s
665665
|result| with a "{{NotFoundError}}" {{DOMException}} and abort these steps.
666666
1. [=Assert=]: |entry| is a [=file entry=].
667667

668-
1. Let |lockResult| be the result of [=file system entry/lock/take|taking a lock=]
668+
1. Let |lockResult| be the result of [=file system entry/lock/take a lock|taking a lock=]
669669
with "`exclusive`" on |entry|.
670670

671671
1. [=Queue a storage task=] with |global| to run these steps:

0 commit comments

Comments
 (0)