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::move() method #317

Closed
wants to merge 8 commits into from
Closed

Conversation

a-sully
Copy link
Collaborator

@a-sully a-sully commented Aug 6, 2021

See MoveAndRename.md


Preview | Diff


Preview | Diff

@a-sully
Copy link
Collaborator Author

a-sully commented Aug 6, 2021

Note that at this point the changes to the explainer are still very much WIP.

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Aug 12, 2021
Currently, it is not possible to move or rename a file or directory
without creating a new file/directory, copying over data (recursively,
in the case of a directory), and removing the original.

This CL allows for the atomic moving of a file or directory on the
local file system without needing to duplicate data.

Moves to non-local file systems will are not guaranteed to be atomic
and will involve duplicating data.

PR: WICG/file-system-access#317

Bug: 1140805
Change-Id: I774ed1d9616249b6ecc80783db48a7bfee915aab
@pwnall
Copy link
Collaborator

pwnall commented Aug 16, 2021

@a-sully Could you please hash out an alternative where the API throws on non-atomic moves?

I think it's worth discussing the benefits (no performance cliff, more flexibility in handling errors for the app, less complexity for browser implementers translating to less room for implementation-specific behavior) versus the costs (potential for errors not caught in development, apps need code to handle the cross-filesystem case).

Also, we should discuss doing different things for moving files vs directories. Moving a large directory across the OPFS -> file system boundary means locking and possibly performing checks (Safe Browsing in Chrome) for an unbounded number of files.

@a-sully
Copy link
Collaborator Author

a-sully commented Aug 16, 2021

@pwnall I've updated the description to talk about the things you mentioned. To be clear, are you talking about throwing on all moves which we cannot guarantee to be atomic (moves to non-local filesystems) or only when we attempt said move and it fails?

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Aug 27, 2021
Currently, it is not possible to move or rename a file or directory
without creating a new file/directory, copying over data (recursively,
in the case of a directory), and removing the original.

This CL allows for the atomic moving of a file or directory on the
local file system without needing to duplicate data.

Moves to non-local file systems will are not guaranteed to be atomic
and will involve duplicating data.

PR: WICG/file-system-access#317

Bug: 1140805
Change-Id: I774ed1d9616249b6ecc80783db48a7bfee915aab
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Aug 31, 2021
Currently, it is not possible to move or rename a file or directory
without creating a new file/directory, copying over data (recursively,
in the case of a directory), and removing the original.

This CL allows for the atomic moving of a file or directory on the
local file system without needing to duplicate data.

Moves to non-local file systems will are not guaranteed to be atomic
and will involve duplicating data.

PR: WICG/file-system-access#317

Bug: 1140805
Change-Id: I774ed1d9616249b6ecc80783db48a7bfee915aab
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Aug 31, 2021
Currently, it is not possible to move or rename a file or directory
without creating a new file/directory, copying over data (recursively,
in the case of a directory), and removing the original.

This CL allows for the atomic moving of a file or directory on the
local file system without needing to duplicate data.

Moves to non-local file systems will are not guaranteed to be atomic
and will involve duplicating data.

PR: WICG/file-system-access#317

Bug: 1140805
Change-Id: I774ed1d9616249b6ecc80783db48a7bfee915aab
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 3, 2021
Currently, it is not possible to move or rename a file or directory
without creating a new file/directory, copying over data (recursively,
in the case of a directory), and removing the original.

This CL allows for the atomic moving of a file or directory on the
local file system without needing to duplicate data.

Moves to non-local file systems will are not guaranteed to be atomic
and will involve duplicating data.

PR: WICG/file-system-access#317

Bug: 1140805
Change-Id: I774ed1d9616249b6ecc80783db48a7bfee915aab
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 3, 2021
Currently, it is not possible to move or rename a file or directory
without creating a new file/directory, copying over data (recursively,
in the case of a directory), and removing the original.

This CL allows for the atomic moving of a file or directory on the
local file system without needing to duplicate data.

Moves to non-local file systems will are not guaranteed to be atomic
and will involve duplicating data.

PR: WICG/file-system-access#317

Bug: 1140805
Change-Id: I774ed1d9616249b6ecc80783db48a7bfee915aab
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 7, 2021
Currently, it is not possible to move or rename a file or directory
without creating a new file/directory, copying over data (recursively,
in the case of a directory), and removing the original.

This CL allows for the atomic moving of a file or directory on the
local file system without needing to duplicate data.

Moves to non-local file systems will are not guaranteed to be atomic
and will involve duplicating data.

PR: WICG/file-system-access#317

Bug: 1140805
Change-Id: I774ed1d9616249b6ecc80783db48a7bfee915aab
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 7, 2021
Currently, it is not possible to move or rename a file or directory
without creating a new file/directory, copying over data (recursively,
in the case of a directory), and removing the original.

This CL allows for the atomic moving of a file or directory on the
local file system without needing to duplicate data.

Moves to non-local file systems will are not guaranteed to be atomic
and will involve duplicating data.

PR: WICG/file-system-access#317

Bug: 1140805
Change-Id: I774ed1d9616249b6ecc80783db48a7bfee915aab
@a-sully a-sully changed the title Add FileSystemHandle::move() method Add FileSystemHandle::move() and method Sep 7, 2021
@a-sully a-sully changed the title Add FileSystemHandle::move() and method Add FileSystemHandle::move() and FileSystemHandle::rename() methods Sep 7, 2021
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 7, 2021
Currently, it is not possible to move or rename a file or directory
without creating a new file/directory, copying over data (recursively,
in the case of a directory), and removing the original.

This CL allows for the atomic moving of a file or directory on the
local file system without needing to duplicate data.

Moves to non-local file systems will are not guaranteed to be atomic
and will involve duplicating data.

PR: WICG/file-system-access#317

Bug: 1140805
Change-Id: I774ed1d9616249b6ecc80783db48a7bfee915aab
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 8, 2021
Currently, it is not possible to move or rename a file or directory
without creating a new file/directory, copying over data (recursively,
in the case of a directory), and removing the original.

This CL allows for the atomic moving of a file or directory on the
local file system without needing to duplicate data.

Moves to non-local file systems will are not guaranteed to be atomic
and will involve duplicating data.

PR: WICG/file-system-access#317

Bug: 1140805
Change-Id: I774ed1d9616249b6ecc80783db48a7bfee915aab
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 8, 2021
Currently, it is not possible to move or rename a file or directory
without creating a new file/directory, copying over data (recursively,
in the case of a directory), and removing the original.

This CL allows for the atomic moving of a file or directory on the
local file system without needing to duplicate data.

Moves to non-local file systems will are not guaranteed to be atomic
and will involve duplicating data.

PR: WICG/file-system-access#317

Bug: 1140805
Change-Id: I774ed1d9616249b6ecc80783db48a7bfee915aab
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 8, 2021
Currently, it is not possible to move or rename a file or directory
without creating a new file/directory, copying over data (recursively,
in the case of a directory), and removing the original.

This CL allows for the atomic moving of a file or directory on the
local file system without needing to duplicate data.

Moves to non-local file systems will are not guaranteed to be atomic
and will involve duplicating data.

PR: WICG/file-system-access#317

Bug: 1140805
Change-Id: I774ed1d9616249b6ecc80783db48a7bfee915aab
Copy link
Collaborator

@pwnall pwnall left a comment

Choose a reason for hiding this comment

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

The explainer and spec changes LGTM, given the idea we're proposing.

EXPLAINER.md Outdated Show resolved Hide resolved
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 9, 2021
Currently, it is not possible to move or rename a file or directory
without creating a new file/directory, copying over data (recursively,
in the case of a directory), and removing the original.

This CL allows for the atomic moving of a file or directory on the
local file system without needing to duplicate data.

Moves to non-local file systems will are not guaranteed to be atomic
and will involve duplicating data.

PR: WICG/file-system-access#317

Bug: 1140805
Change-Id: I774ed1d9616249b6ecc80783db48a7bfee915aab
MoveAndRename.md Outdated Show resolved Hide resolved
MoveAndRename.md Outdated Show resolved Hide resolved
MoveAndRename.md Outdated Show resolved Hide resolved
@a-sully
Copy link
Collaborator Author

a-sully commented Sep 14, 2021

Just a quick drive-by review, since I will need to document this on https://web.dev/file-system-access/. Do you have a Chromium bug for me to subscribe to and see when this ships (or can be tested) and thus needs documentation?

@tomayac Just created a launch bug: https://crbug.com/1249662

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Sep 22, 2021
…temHandle::rename() methods, a=testonly

Automatic update from web-platform-tests
Add FileSystemHandle::move() and FileSystemHandle::rename() methods

Currently, it is not possible to move or rename a file or directory
without creating a new file/directory, copying over data (recursively,
in the case of a directory), and removing the original.

This CL allows for the atomic moving of a file or directory on the
local file system without needing to duplicate data.

Moves to non-local file systems will are not guaranteed to be atomic
and will involve duplicating data.

PR: WICG/file-system-access#317

Bug: 1140805
Change-Id: I774ed1d9616249b6ecc80783db48a7bfee915aab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2984739
Commit-Queue: Austin Sullivan <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Victor Costan <[email protected]>
Reviewed-by: Marijn Kruisselbrink <[email protected]>
Cr-Commit-Position: refs/heads/main@{#919810}

--

wpt-commits: 72023078617ed82a4c707c7966fffe42b0f0e66a
wpt-pr: 29686
aosmond pushed a commit to aosmond/gecko that referenced this pull request Sep 24, 2021
…temHandle::rename() methods, a=testonly

Automatic update from web-platform-tests
Add FileSystemHandle::move() and FileSystemHandle::rename() methods

Currently, it is not possible to move or rename a file or directory
without creating a new file/directory, copying over data (recursively,
in the case of a directory), and removing the original.

This CL allows for the atomic moving of a file or directory on the
local file system without needing to duplicate data.

Moves to non-local file systems will are not guaranteed to be atomic
and will involve duplicating data.

PR: WICG/file-system-access#317

Bug: 1140805
Change-Id: I774ed1d9616249b6ecc80783db48a7bfee915aab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2984739
Commit-Queue: Austin Sullivan <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Victor Costan <[email protected]>
Reviewed-by: Marijn Kruisselbrink <[email protected]>
Cr-Commit-Position: refs/heads/main@{#919810}

--

wpt-commits: 72023078617ed82a4c707c7966fffe42b0f0e66a
wpt-pr: 29686
@szewai
Copy link

szewai commented Oct 19, 2021

Hello @a-sully @pwnall @mikewest @mkruisselbrink @tomayac, is there any update on this? Can this be merged?

Gabisampaio pushed a commit to Gabisampaio/wpt that referenced this pull request Nov 18, 2021
Currently, it is not possible to move or rename a file or directory
without creating a new file/directory, copying over data (recursively,
in the case of a directory), and removing the original.

This CL allows for the atomic moving of a file or directory on the
local file system without needing to duplicate data.

Moves to non-local file systems will are not guaranteed to be atomic
and will involve duplicating data.

PR: WICG/file-system-access#317

Bug: 1140805
Change-Id: I774ed1d9616249b6ecc80783db48a7bfee915aab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2984739
Commit-Queue: Austin Sullivan <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Victor Costan <[email protected]>
Reviewed-by: Marijn Kruisselbrink <[email protected]>
Cr-Commit-Position: refs/heads/main@{#919810}
@hcldan
Copy link

hcldan commented Jan 13, 2022

@a-sully
The https://web.dev/file-system-access/
article makes it sound like you can only rename files and move directories... at least that's how I read it. Maybe change the wording? Unless that's how it works... in which case... why?

Files and folders can be renamed or moved to a new location by calling rename() or move() on the FileSystemFileHandle or FileSystemDirectoryHandle respectively.

@tomayac
Copy link
Contributor

tomayac commented Jan 13, 2022

This is what's in the article:

Files and folders can be renamed or moved to a new location by calling rename() or move() on the FileSystemFileHandle or FileSystemDirectoryHandle respectively. For move(), the first parameter is a FileSystemDirectoryHandle.

What do you want to change?

@hcldan
Copy link

hcldan commented Jan 13, 2022

Files and folders can be renamed or moved to a new location by calling move() on the FileSystemHandle.

@a-sully
Copy link
Collaborator Author

a-sully commented Jan 13, 2022

@tomayac we actually just landed a change which consolidates the move() and rename() methods into one overloaded move() method. I've uploaded a new patch on this PR with the changes.

@a-sully a-sully changed the title Add FileSystemHandle::move() and FileSystemHandle::rename() methods Add FileSystemHandle::move() method Jan 13, 2022
@hcldan
Copy link

hcldan commented Jan 13, 2022

@tomayac I updated my answer in light of the new api. There might be better ways to phrase it.
Actually, the reduction to 1 api removes the ambiguity of the "respectively" ending.

@tomayac
Copy link
Contributor

tomayac commented Jan 14, 2022

Please see GoogleChrome/web.dev#7172 with these changes.

@hcldan
Copy link

hcldan commented Jan 14, 2022

--- nevermind ---

Actually... if you check this comment revision history (I don't know how to get it back), I realize what I'm doing wrong...
but the error message could use some love.

@hcldan
Copy link

hcldan commented Jan 14, 2022

image

image

Not sure I understand this one though...

@hcldan
Copy link

hcldan commented Jan 14, 2022

can you not move dirs with things in them?

@a-sully
Copy link
Collaborator Author

a-sully commented Jan 14, 2022

@hcldan it looks like there's been some miscommunication on our side. Due to all of the open questions regarding cross-file-system moves, move() is temporarily disabled for directories (hence the abort errors) and moves outside of the Origin-Private File System. This feature is currently only available in the OPFS to those with the AccessHandles origin trial enabled.

@tomayac would you mind updating web.dev to reflect this? (see the launch bug.)

We would like to support this feature more broadly eventually, but to do so we need to address the open questions mentioned in this PR. Apologies for the confusion.

@hcldan
Copy link

hcldan commented Jan 14, 2022

But both of these dirs are within the OPFS.. they aren't cross filesystem... Even those dir moves are disabled?

@a-sully
Copy link
Collaborator Author

a-sully commented Jan 14, 2022

Yes, directory moves within OPFS are (annoyingly) not atomic so those have been temporarily blocked, as well.

@hcldan
Copy link

hcldan commented Jan 14, 2022

temporarily blocked

How temporarily (how long)?

@tomayac
Copy link
Contributor

tomayac commented Jan 17, 2022

@tomayac would you mind updating web.dev to reflect this? (see the launch bug.)

Done: GoogleChrome/web.dev@0f2f161.

@hcldan
Copy link

hcldan commented Jan 19, 2022

@hcldan it looks like there's been some miscommunication on our side. Due to all of the open questions regarding cross-file-system moves, move() is temporarily disabled for directories (hence the abort errors) and moves outside of the Origin-Private File System. This feature is currently only available in the OPFS to those with the AccessHandles origin trial enabled.

@tomayac would you mind updating web.dev to reflect this? (see the launch bug.)

We would like to support this feature more broadly eventually, but to do so we need to address the open questions mentioned in this PR. Apologies for the confusion.

@a-sully Thank you for this statement, but it brings up another question for me.
When chrome 99 ships there won't be a flag anymore to rope off AccessHandles. Will this limitation ship in chrome 99, or do you expect there will be a fix for this "soon" (before chrome 99 ships)?

@annevk
Copy link

annevk commented Feb 11, 2022

@a-sully could you please rebase these commits against https://github.com/whatwg/fs and create a PR there?

@a-sully
Copy link
Collaborator Author

a-sully commented Mar 7, 2022

This issue has been ported to whatwg/fs#10

@a-sully a-sully closed this Mar 7, 2022
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 14, 2022
Currently, it is not possible to move or rename a file or directory
without creating a new file/directory, copying over data (recursively,
in the case of a directory), and removing the original.

This CL allows for the atomic moving of a file or directory on the
local file system without needing to duplicate data.

Moves to non-local file systems will are not guaranteed to be atomic
and will involve duplicating data.

PR: WICG/file-system-access#317

Bug: 1140805
Change-Id: I774ed1d9616249b6ecc80783db48a7bfee915aab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2984739
Commit-Queue: Austin Sullivan <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Victor Costan <[email protected]>
Reviewed-by: Marijn Kruisselbrink <[email protected]>
Cr-Commit-Position: refs/heads/main@{#919810}
NOKEYCHECK=True
GitOrigin-RevId: 89be8a84bf5c962fa363bd093f4f125ac923838c
@a-sully a-sully deleted the move-handle branch June 14, 2023 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants