Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FileSystemHandle.remove method #9

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

a-sully
Copy link
Collaborator

@a-sully a-sully commented Mar 7, 2022

Migrated from WICG/file-system-access#283 (see #2)

Addresses WICG/file-system-access#214

Adds the ability for a file or directory to delete itself. See the proposal: https://github.com/whatwg/fs/blob/main/proposals/Remove.md

Currently, it is not possible to remove a file or directory given its handle. You must obtain the handle of the parent directory and call FileSystemDirectoryHandle.removeEntry().

This would enable the common use case where you obtain a file handle from showSaveFilePicker(), but then decide you don't want to save after all, and delete the file, or clearing an entire bucket file system.

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to make your membership of the googlers GitHub organization public to appease the IPR bot.

index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Dec 9, 2022
Removes the extra check added in https://crrev.com/c/3123735. See
recent discussion on the spec here:
whatwg/fs#9 (comment)

Bug: 1114923, 1399660
Change-Id: I0afd561238ae44dfa055e6fff234e801ee8de616
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Dec 9, 2022
Spec PR: whatwg/fs#9

Bug: 1114923
Change-Id: Ie52068e0053cf3a1b693e09c5623eb4b42dd6eb9
aarongable pushed a commit to chromium/chromium that referenced this pull request Dec 9, 2022
Removes the extra check added in https://crrev.com/c/3123735. See
recent discussion on the spec here:
whatwg/fs#9 (comment)

Bug: 1114923, 1399660
Change-Id: I0afd561238ae44dfa055e6fff234e801ee8de616
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4090632
Auto-Submit: Austin Sullivan <[email protected]>
Reviewed-by: Daseul Lee <[email protected]>
Commit-Queue: Austin Sullivan <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1081696}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Dec 9, 2022
Removes the extra check added in https://crrev.com/c/3123735. See
recent discussion on the spec here:
whatwg/fs#9 (comment)

Bug: 1114923, 1399660
Change-Id: I0afd561238ae44dfa055e6fff234e801ee8de616
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4090632
Auto-Submit: Austin Sullivan <[email protected]>
Reviewed-by: Daseul Lee <[email protected]>
Commit-Queue: Austin Sullivan <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1081696}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Dec 9, 2022
Removes the extra check added in https://crrev.com/c/3123735. See
recent discussion on the spec here:
whatwg/fs#9 (comment)

Bug: 1114923, 1399660
Change-Id: I0afd561238ae44dfa055e6fff234e801ee8de616
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4090632
Auto-Submit: Austin Sullivan <[email protected]>
Reviewed-by: Daseul Lee <[email protected]>
Commit-Queue: Austin Sullivan <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1081696}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Dec 9, 2022
Spec PR: whatwg/fs#9

Bug: 1114923
Change-Id: Ie52068e0053cf3a1b693e09c5623eb4b42dd6eb9
aarongable pushed a commit to chromium/chromium that referenced this pull request Dec 9, 2022
Spec PR: whatwg/fs#9

Bug: 1114923
Change-Id: Ie52068e0053cf3a1b693e09c5623eb4b42dd6eb9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4073126
Reviewed-by: Daseul Lee <[email protected]>
Commit-Queue: Austin Sullivan <[email protected]>
Auto-Submit: Austin Sullivan <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1081718}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Dec 9, 2022
Spec PR: whatwg/fs#9

Bug: 1114923
Change-Id: Ie52068e0053cf3a1b693e09c5623eb4b42dd6eb9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4073126
Reviewed-by: Daseul Lee <[email protected]>
Commit-Queue: Austin Sullivan <[email protected]>
Auto-Submit: Austin Sullivan <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1081718}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Dec 10, 2022
Spec PR: whatwg/fs#9

Bug: 1114923
Change-Id: Ie52068e0053cf3a1b693e09c5623eb4b42dd6eb9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4073126
Reviewed-by: Daseul Lee <[email protected]>
Commit-Queue: Austin Sullivan <[email protected]>
Auto-Submit: Austin Sullivan <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1081718}
@a-sully a-sully changed the title Add FileSystemHandle::Remove method Add FileSystemHandle.remove method Jan 17, 2023
@a-sully
Copy link
Collaborator Author

a-sully commented Jan 18, 2023

Since this is a new method, should we try to do task queueing correctly from the get go?

I've attempted to do this in the latest patchset (thank you for finishing off whatwg/storage#155!), but I'm not sure whether we should be queueing everything or just the bits that may touch quota? (in this case, the actual removal of the entry). This could alternatively look like:

1. Let |result| be [=a new promise=].
1. Run these steps [=in parallel=]:
  1. Check permissions
  1. Grab lock (on a parallel queue)
  1. Queue a task on the storage task source to actually remove the entry
1. Return |result|.

...but based on your comment here (#3 (comment)) it seems like the promise must be resolved/rejected on some task source, so maybe it should be this?

1. Let |result| be [=a new promise=].
1. Queue a global task to run these steps:
  1. Check permissions
  1. Grab lock (on a parallel queue)
  1. Queue a task on the storage task source to actually remove the entry
1. Return |result|.

Please let me know if you have a preference :)

index.bs Outdated Show resolved Hide resolved
@a-sully
Copy link
Collaborator Author

a-sully commented Jan 18, 2023

1. Let |result| be [=a new promise=].
1. Run these steps [=in parallel=]:
  1. Check permissions
  1. Grab lock (on a parallel queue)
  1. Queue a task on the storage task source to actually remove the entry
1. Return |result|.

I realized when putting together #95 that (I think) the parallel queue can be hidden to just the lock acquiring/releasing algorithms so the "Grab lock" step may actually not have to change

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to have a good delineation between the main thread and the storage thread operations.

The method and the eventual task run in the main thread and can access JS.

What's missing here is an "in parallel" section that runs in some other thread and deals with locks and the file system.

Or am I misunderstanding something?

index.bs Outdated Show resolved Hide resolved
@a-sully
Copy link
Collaborator Author

a-sully commented Feb 2, 2023

This doesn't seem to have a good delineation between the main thread and the storage thread operations.

The method and the eventual task run in the main thread and can access JS.

What's missing here is an "in parallel" section that runs in some other thread and deals with locks and the file system.

Or am I misunderstanding something?

You're correct, and I've updated this in the latest patchset. It's still not perfect since file locking is still done in parallel on the main thread, but once #95 adds the new framework for file locking we can follow that pattern. I'm happy to do that in a follow-up

@a-sully
Copy link
Collaborator Author

a-sully commented Feb 2, 2023

Also, #73 (comment) is relevant here, too... we may need to specify what taking locks on a directory looks like (i.e. you can't take the lock if a containing file is locked)

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
@a-sully a-sully reopened this Jun 22, 2023
@a-sully
Copy link
Collaborator Author

a-sully commented Jul 17, 2023

Hi all, I've updated this PR to make use of the various infrastructural changes that have merged recently (primarily #95 and #96). Please take a look at the updated PR. Thanks!

|accessResult|'s [=file system access result/error name=] and
abort these steps.

1. If |entry| is `null`, [=queue a storage task=] with |global| to [=/reject=]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: https://infra.spec.whatwg.org doesn't use markup for null.

Comment on lines +485 to +487
1. Attempt to remove |child| from the underlying file system.
If that throws an exception, [=/reject=] |result| with
that exception and abort these steps.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems weird that this would happen on the main thread.


Issue(11): Better specify what possible exceptions this could throw.

1. [=Enqueue the following steps=] to the [=file system queue=]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need nested file system queue steps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants