Skip to content

vfs: fix AddVirtual ignoring isDir - #9949

Merged
ncw merged 1 commit into
rclone:masterfrom
hsdfat:vfs-addvirtual-isdir-9310
Sep 21, 2026
Merged

ncw merged 1 commit into
rclone:masterfrom
hsdfat:vfs-addvirtual-isdir-9310

Conversation

@hsdfat

@hsdfat hsdfat commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

What does this change do?

VFS.AddVirtual takes an isDir argument, but it always called Dir.AddVirtual with false. Adding a virtual directory therefore added a file, and nothing could then be added inside it. This passes isDir through, as pointed out in #9310.

The only caller today is the VFS cache, which always passes false, so mount and serve behave as before. The fix matters for any caller that adds directories.

Testing

  • TestVFSAddVirtual adds a virtual file, then a virtual directory, then a file inside that directory, and checks each one with Stat. On master the directory comes back as a file, and adding the file inside it fails with "file already exists".
  • I ran it on local, which goes through the StatParent branch, and with -remote :memory:, which goes through the mkdirAll branch used by backends that can't have empty directories.
  • These pass: go build ./..., make quicktest, go test ./vfs/... (local and :memory:), go vet ./vfs/ and golangci-lint run ./vfs/....

Linked issue

#9310. This fixes the isDir bug confirmed there. It does not add the rc command the issue asks for.

Checklist

  • This change is trivial OR it has been discussed and agreed in the linked issue.
  • I have read the contribution guidelines.
  • (If I used AI tools to help write this code) I have read and understood the AI-assisted contributions guidance, and I have tested and take ownership of this change myself.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate. (No doc change needed: internal function, and its comment already says "file or dir".)
  • All commit messages are in house style.
  • (Backend changes only) test_all passes for this backend. n/a, not a backend change.
  • This Pull Request is ready for review.

VFS.AddVirtual always added a file entry to the directory cache, even
when called with isDir set, so a virtual directory showed up as a file
and nothing could be added inside it.

See rclone#9310
@hsdfat
hsdfat requested a review from ncw as a code owner September 19, 2026 15:00

@ncw ncw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you :-)

@ncw
ncw merged commit ebb1cc1 into rclone:master Sep 21, 2026
9 checks passed
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.

2 participants