Skip to content

Add FileSystemHandle::move() method#317

Closed
a-sully wants to merge 8 commits into
remove-handlefrom
move-handle
Closed

Add FileSystemHandle::move() method#317
a-sully wants to merge 8 commits into
remove-handlefrom
move-handle

Conversation

@a-sully

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

Copy link
Copy Markdown
Collaborator

See MoveAndRename.md


Preview | Diff


Preview | Diff

@a-sully

a-sully commented Aug 6, 2021

Copy link
Copy Markdown
Collaborator Author

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

pwnall commented Aug 16, 2021

Copy link
Copy Markdown
Collaborator

@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

a-sully commented Aug 16, 2021

Copy link
Copy Markdown
Collaborator Author

@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

@pwnall pwnall left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment thread EXPLAINER.md
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
Comment thread MoveAndRename.md Outdated
Comment thread MoveAndRename.md Outdated
Comment thread MoveAndRename.md Outdated
@a-sully

a-sully commented Sep 14, 2021

Copy link
Copy Markdown
Collaborator Author

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 <asully@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
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 <asully@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/main@{#919810}

--

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

szewai commented Oct 19, 2021

Copy link
Copy Markdown

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 <asully@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/main@{#919810}
@hcldan

hcldan commented Jan 13, 2022

Copy link
Copy Markdown

@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

tomayac commented Jan 13, 2022

Copy link
Copy Markdown
Contributor

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

hcldan commented Jan 13, 2022

Copy link
Copy Markdown

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

@a-sully

a-sully commented Jan 13, 2022

Copy link
Copy Markdown
Collaborator Author

@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

hcldan commented Jan 13, 2022

Copy link
Copy Markdown

@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

tomayac commented Jan 14, 2022

Copy link
Copy Markdown
Contributor

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

@hcldan

hcldan commented Jan 14, 2022

Copy link
Copy Markdown

--- 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

hcldan commented Jan 14, 2022

Copy link
Copy Markdown

image

image

Not sure I understand this one though...

@hcldan

hcldan commented Jan 14, 2022

Copy link
Copy Markdown

can you not move dirs with things in them?

@a-sully

a-sully commented Jan 14, 2022

Copy link
Copy Markdown
Collaborator Author

@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

hcldan commented Jan 14, 2022

Copy link
Copy Markdown

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

@a-sully

a-sully commented Jan 14, 2022

Copy link
Copy Markdown
Collaborator Author

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

@hcldan

hcldan commented Jan 14, 2022

Copy link
Copy Markdown

temporarily blocked

How temporarily (how long)?

@tomayac

tomayac commented Jan 17, 2022

Copy link
Copy Markdown
Contributor

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

Done: GoogleChrome/web.dev@0f2f161.

@hcldan

hcldan commented Jan 19, 2022

Copy link
Copy Markdown

@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

annevk commented Feb 11, 2022

Copy link
Copy Markdown

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

@a-sully

a-sully commented Mar 7, 2022

Copy link
Copy Markdown
Collaborator Author

This issue has been ported to whatwg/fs#10

@a-sully a-sully closed this Mar 7, 2022
@a-sully a-sully deleted the move-handle branch June 14, 2023 05:22
jwidar pushed a commit to jwidar/LatencyZeroGithub that referenced this pull request Sep 16, 2025
…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 <asully@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/main@{#919810}

--

wpt-commits: 72023078617ed82a4c707c7966fffe42b0f0e66a
wpt-pr: 29686
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