Skip to content

Commit 957ffea

Browse files
committed
retry specifying remove after whatwg#95
1 parent bee4f50 commit 957ffea

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

index.bs

+92
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ interface FileSystemHandle {
332332
readonly attribute USVString name;
333333

334334
Promise<boolean> isSameEntry(FileSystemHandle other);
335+
Promise<undefined> remove(optional FileSystemRemoveOptions options = {});
335336
};
336337
</xmp>
337338

@@ -416,6 +417,97 @@ The <dfn method for=FileSystemHandle>isSameEntry(|other|)</dfn> method steps are
416417

417418
</div>
418419

420+
### The {{FileSystemHandle/remove()}} method ### {#api-filesystemhandle-remove}
421+
422+
<div class="note domintro">
423+
: await |handle| . {{FileSystemHandle/remove()|remove}}()
424+
: await |handle| . {{FileSystemHandle/remove()|remove}}({ {{FileSystemRemoveOptions/recursive}}: false })
425+
:: Deletes the [=file system entry=] [=locate an entry|locatable=] by
426+
|handle|'s [=FileSystemHandle/locator=] from the underlying file system.
427+
428+
Attempting to delete a file or directory that does not exist is considered
429+
success, while attempting to delete a non-empty directory will
430+
result in a promise rejection.
431+
432+
: await |handle| . {{FileSystemHandle/remove()|remove}}({ {{FileSystemRemoveOptions/recursive}}: true })
433+
:: Deletes the [=file system entry=] [=locate an entry|locatable=] by
434+
|handle|'s [=FileSystemHandle/locator=] from the underlying file system.
435+
If that [=file system entry=] is a [=directory entry=],
436+
its contents will also be deleted recursively.
437+
438+
Attempting to delete a file or directory that does not exist is considered
439+
success.
440+
</div>
441+
442+
<div algorithm>
443+
The <dfn method for=FileSystemHandle>remove(|options|)</dfn> method steps are:
444+
445+
1. Let |result| be [=a new promise=].
446+
1. Let |locator| be [=this=]'s [=FileSystemHandle/locator=].
447+
1. Let |global| be [=this=]'s [=relevant global object=].
448+
1. Let |isInABucketFileSystem| be true if
449+
[=this=] [=FileSystemHandle/is in a bucket file system=];
450+
otherwise false.
451+
1. [=Enqueue the following steps=] to the [=file system queue=]:
452+
1. Let |entry| be the result of [=locating an entry=] given |locator|.
453+
1. Let |accessResult| be the result of running |entry|'s
454+
[=file system entry/request access=] given "`readwrite`".
455+
1. If |accessResult|'s [=file system access result/permission state=]
456+
is not "{{PermissionState/granted}}", [=queue a storage task=] with
457+
|global| to [=/reject=] |result| with a {{DOMException}} of
458+
|accessResult|'s [=file system access result/error name=] and
459+
abort these steps.
460+
461+
1. If |entry| is `null`, [=queue a storage task=] with |global| to [=/reject=]
462+
|result| with a "{{NotFoundError}}" {{DOMException}} and abort these steps.
463+
464+
1. Let |lockResult| be the result of [=file entry/lock/take|taking a lock=]
465+
with "`exclusive`" on |entry|.
466+
467+
Issue(137): Support locking directory entries.
468+
469+
1. [=Queue a storage task=] with |global| to run these steps:
470+
1. If |lockResult| is "`failure`", [=/reject=] |result| with a
471+
"{{NoModificationAllowedError}}" {{DOMException}} and abort these steps.
472+
473+
1. If |entry| is a [=directory entry=]:
474+
1. If |entry|'s [=directory entry/children=] [=set/is empty=] and
475+
|options|["{{FileSystemRemoveOptions/recursive}}"] is false,
476+
[=/reject=] |result| with an
477+
"{{InvalidModificationError}}" {{DOMException}} and abort these steps.
478+
479+
1. Let |isTheRootOfABucketFileSystem| be true if
480+
|isInABucketFileSystem| is true and
481+
|entry|'s [=file system entry/parent=] is `null`;
482+
otherwise false.
483+
1. If |isTheRootOfABucketFileSystem| is true:
484+
1. [=set/For each=] |child| of |entry|'s [=directory entry/children=]:
485+
1. Attempt to remove |child| from the underlying file system.
486+
If that throws an exception, [=/reject=] |result| with
487+
that exception and abort these steps.
488+
1. Set |entry|'s [=directory entry/children=] to an empty [=/set=].
489+
1. [=/Resolve=] |result| with `undefined` and abort these steps.
490+
491+
1. If |entry|'s [=file system entry/parent=] is not `null`,
492+
[=set/remove=] |entry| from |entry|'s [=file system entry/parent=]'s
493+
[=directory entry/children=].
494+
495+
1. Attempt to remove |entry| from the underlying file system.
496+
If that throws an exception, [=/reject=] |result| with that exception
497+
and abort these steps.
498+
499+
Note: If |options|["{{FileSystemRemoveOptions/recursive}}"] is true,
500+
the removal can fail non-atomically. Some files or directories might
501+
have been removed while other files or directories still exist.
502+
503+
Issue(11): Better specify what possible exceptions this could throw.
504+
505+
1. [=/Resolve=] |result| with `undefined`.
506+
507+
1. Return |result|.
508+
509+
</div>
510+
419511
## The {{FileSystemFileHandle}} interface ## {#api-filesystemfilehandle}
420512

421513
<xmp class=idl>

0 commit comments

Comments
 (0)