-
Notifications
You must be signed in to change notification settings - Fork 19
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.move method #10
base: main
Are you sure you want to change the base?
Conversation
I'd suggest we don't include the |
Any updates on this? Thanks @a-sully for working on this though. When this gets merged what exactly happens? Does this feature get added to all JavaScript engines supporting the whatwg standard? |
Open questions:
|
…re is added to browsers whatwg/fs#10" This reverts commit 53510cc.
This comment in move.md from the patch partly answers these questions (I presume what's meant here is "All handles to entries"):
That doesn't answer about FileHandles or SyncAccessHandles to a file being moved/renamed.
This is discussed in move.md, but there's no resolution of the discussion. |
Right now the justification for the answer about moving directories is based on move.md, which isn't here. |
Note that the WPT tests for move() encode several things not in this spec related to what are valid names: testing that you can't rename a file to "Lorem." (no trailing periods - this isn't specified) The spec says: "A valid file name is a string that is not an empty string, is not equal to "." or "..", and does not contain '/' or any other character used as path separator on the underlying platform." |
The tests also test that move() can overwrite an existing file. This is mentioned nowhere in the spec, and the spec says "Attempt to move entry to destination in the underlying file system." which does not to me indicate it should overwrite. (It also checks that having a WritableFileStream open on the destination blocks move()) |
Also file.move(dir, "") should fail, per the spec; the wpt tests assume it's the same as file.move(dir) |
Thanks for bringing up these questions! Apologies for the confusion, Move.md is a bit outdated since it was written before the locking mechanisms for SyncAccessHandles were created. I'm planning to update this PR once #21 lands to incorporate those locking mechanisms. For now, to respond to your questions...
#30 is intended to address these. Since a FileSystemHandle maps to a path, these handles will dangle once the underlying file/dir is moved.
If a SyncAccessHandle is being created, presumably whichever operation is able to grab their respective lock will win and the other will reject. As for
Yes. A couple examples:
In these cases, the promise will be rejected with an
You are correct. And I'm wondering whether this is the right behavior in the first place... I think there's a strong argument to be made that we should reject a move to a path that already exists and allow the site to delete the destination handle and try again if they truly want it overwritten. |
Good catch. We should probably update the WPTs and not the spec? Ideally the "is this a safe file" code can be shared between |
yes, the WPTs should be updated |
move("") rejects with a TypeError, while move(dir, "") succeeds (by ignoring the second arg). Make this consistent by always rejecting if there's an invalid name, as specified in https://wicg.github.io/file-system-access/#valid-file-name See whatwg/fs#10 (comment) Bug: 1327741 Change-Id: Ifd8457df05aad7f75007ff5eece6237a09098a94
Attempts to move a directory to within itself should fail. |
The wpt tests check that moving a file to the same name succeeds (I.e. succeeds in doing nothing). (They don't check if moving a directory to the same name succeeds, note.) This behavior does not appear to be anywhere in the spec here; it basically says "attempts to move it in the underlying filesystem" which could fail or succeed. |
I wonder if the fact that move-that-doesn't-move succeeds in chrome is related to the fact that it currently silently allows a move() to overwrite a file. At this moment, we fail that WPT test because we check if the destination file exists and if so, fail. |
This codifies the behavior agreed upon here: whatwg/fs#10 (comment) See go/fsa-overwriting-moves for more context Bug: 1366652, 1381621 Change-Id: I24d8ff94ebd9f6b6a8f2ffe9a0e30623193e7eab Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4076968 Auto-Submit: Austin Sullivan <[email protected]> Reviewed-by: Daseul Lee <[email protected]> Commit-Queue: Daseul Lee <[email protected]> Cr-Commit-Position: refs/heads/main@{#1079294}
…ile moves are allowed, a=testonly Automatic update from web-platform-tests FSA: Make WPTs assert that overwriting file moves are allowed This codifies the behavior agreed upon here: whatwg/fs#10 (comment) See go/fsa-overwriting-moves for more context Bug: 1366652, 1381621 Change-Id: I24d8ff94ebd9f6b6a8f2ffe9a0e30623193e7eab Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4076968 Auto-Submit: Austin Sullivan <[email protected]> Reviewed-by: Daseul Lee <[email protected]> Commit-Queue: Daseul Lee <[email protected]> Cr-Commit-Position: refs/heads/main@{#1079294} -- wpt-commits: ff43fc72820d7c82f5a3383a466a80ca64a6bb05 wpt-pr: 37309
This codifies the behavior agreed upon here: whatwg/fs#10 (comment) See go/fsa-overwriting-moves for more context Bug: 1366652, 1381621 Change-Id: I24d8ff94ebd9f6b6a8f2ffe9a0e30623193e7eab Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4076968 Auto-Submit: Austin Sullivan <[email protected]> Reviewed-by: Daseul Lee <[email protected]> Commit-Queue: Daseul Lee <[email protected]> Cr-Commit-Position: refs/heads/main@{#1079294}
…ile moves are allowed, a=testonly Automatic update from web-platform-tests FSA: Make WPTs assert that overwriting file moves are allowed This codifies the behavior agreed upon here: whatwg/fs#10 (comment) See go/fsa-overwriting-moves for more context Bug: 1366652, 1381621 Change-Id: I24d8ff94ebd9f6b6a8f2ffe9a0e30623193e7eab Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4076968 Auto-Submit: Austin Sullivan <[email protected]> Reviewed-by: Daseul Lee <[email protected]> Commit-Queue: Daseul Lee <[email protected]> Cr-Commit-Position: refs/heads/main@{#1079294} -- wpt-commits: ff43fc72820d7c82f5a3383a466a80ca64a6bb05 wpt-pr: 37309
Partial revert of https://crrev.com/c/3930658. Throwing on overwriting moves does not match POSIX. See discussion on the spec: whatwg/fs#10 (comment) This CL is being cherry-picked to M109 to ensure overwriting moves are allowed in that milestone (which matches the previous behavior) (cherry picked from commit 0eeab37) Bug: 1366652, 1381621 Change-Id: Ic27fb61e7598c4feb8ee770ceb78fe1fbfd28cda Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4048780 Auto-Submit: Austin Sullivan <[email protected]> Reviewed-by: Daseul Lee <[email protected]> Commit-Queue: Daseul Lee <[email protected]> Cr-Original-Commit-Position: refs/heads/main@{#1074882} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4049684 Commit-Queue: Austin Sullivan <[email protected]> Cr-Commit-Position: refs/branch-heads/5414@{chromium#223} Cr-Branched-From: 4417ee5-refs/heads/main@{#1070088}
Agreed! On that note, we're planning to ship Q: Should we scope down this PR to only consider file moves? Ideally this PR would have merged months (when we decided to support |
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! @jesup I've tried to answer all your questions. Apologies for not being able to answer them months ago! (We really needed the above infrastructure changes to appropriately answer many of them.) Please let me know if there's anything I've missed.
Only the handle which
Ditto
We now have a file system queue!
Yes. I've added a note about this in the PR, though since no browser has yet implemented directory moves outside of the BucketFS, that part is admittedly a bit vague for now
Added!
As per this, I've specified that moving across the OPFS boundary is not allowed (for now). I welcome thoughts on #114, as well as thoughts on supporting cross-BucketFS moves
I agree that we shouldn't need to actually call into e.g. |
A few things to note:
|
The behavior of renaming files is inconsistent with the native API. When using the Should I report this issue here or somewhere else? PS My test environment: Win10, Chrome120.0.6099.129 |
AFAICT, this PR doesn't say anything about setting a file's |
Migrated from WICG/file-system-access#317 (see #2)
Addresses WICG/file-system-access#64 and WICG/file-system-access#65
(See WHATWG Working Mode: Changes for more details.)
Preview | Diff