Repository navigation
vfs: fix AddVirtual ignoring isDir - #9949
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change do?
VFS.AddVirtualtakes anisDirargument, but it always calledDir.AddVirtualwithfalse. Adding a virtual directory therefore added a file, and nothing could then be added inside it. This passesisDirthrough, 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
TestVFSAddVirtualadds a virtual file, then a virtual directory, then a file inside that directory, and checks each one withStat. On master the directory comes back as a file, and adding the file inside it fails with "file already exists".StatParentbranch, and with-remote :memory:, which goes through themkdirAllbranch used by backends that can't have empty directories.go build ./...,make quicktest,go test ./vfs/...(local and:memory:),go vet ./vfs/andgolangci-lint run ./vfs/....Linked issue
#9310. This fixes the
isDirbug confirmed there. It does not add the rc command the issue asks for.Checklist
test_allpasses for this backend. n/a, not a backend change.