Skip to content

Add the FileSystemFileHandle.move method#180

Open
valadaptive wants to merge 12 commits intowhatwg:mainfrom
valadaptive:move-redux
Open

Add the FileSystemFileHandle.move method#180
valadaptive wants to merge 12 commits intowhatwg:mainfrom
valadaptive:move-redux

Conversation

@valadaptive
Copy link

@valadaptive valadaptive commented Jan 4, 2026

An earlier version of this was proposed in #10, but stalled out due to complications around moving directories.

When looking into it, I was therefore surprised to find that this method (at least, a subset of it) has shipped in browsers since late 2021!

Apparently, Firefox and WebKit both shipped (early versions of) this method without a flag, and have kept them ever since. Chromium added these methods to the public IDL of FileSystemFileHandle in a commit that claimed only to remove them from FileSystemHandle. (A slightly-later update changed the single-argument version from rename to move.)

I've taken #10 and adjusted it to match what Chrome has actually been shipping, in the hope that it can be standardized and documented. In particular, directory entries can no longer be moved, and the move method has been moved from FileSystemHandle to FileSystemFileHandle.

Aside from just moving things around in the spec, there are a couple other changes:

  • I've reworded the non-normative sections slightly, since Bikeshed now warns if you use the word "may" in a non-normative section.

  • I've removed a couple steps in the algorithm that only exist to handle edge cases around moving directories. These steps were ensuring a directory could not be moved within itself, and ensuring the root of a bucket file system could not be moved.

The rewording is in its own commit, to make it easier to review that diff specifically.


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.

Thank you for tackling this! I hope @a-sully can review this. I left a couple of editorial nits.

index.bs Outdated
</div>

<div algorithm>
The <dfn method for=FileSystemFileHandle>move({{FileSystemDirectoryHandle}}: |destinationDirectory|)</dfn>
Copy link
Member

Choose a reason for hiding this comment

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

We don't list the types here. This should maybe also use <p> as in the output all these algorithms look squished together.

Copy link
Author

Choose a reason for hiding this comment

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

Removed the types from the algorithm headers (hopefully I didn't miss any).

I chose not to use <p> since it currently only appears twice in the entire document, at the footer. If we want to use <p> in more places for clarity, I think it's better to do that consistently as a separate change than to introduce it here.

index.bs Outdated
with "`exclusive`" on |entry|.

1. If |destinationEntry| is not `null`:
1. Let |destinationLockResult| be the result of
Copy link
Member

Choose a reason for hiding this comment

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

Initialize this variable in the outer scope once for clarity as you need it later. And then overwrite it for this non-null case. We usually keep "null" without markup btw, not null, just null.

Copy link
Author

Choose a reason for hiding this comment

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

Initialized it to "not taken", overwriting it inside the conditional.

I also changed all the uses of null in the new section to plain "null". There are some other pre-existing areas that use null; maybe another editorial change for later.

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