vfs: make dir.ForgetAll and friends not forget virtual entries
Before this change dir.ForgetAll and vfs/forget would forget about virtual directory entries. This change preserves them.
This commit is contained in:
parent
06a12f5e27
commit
5db15cb157
2 changed files with 44 additions and 28 deletions
|
@ -269,21 +269,17 @@ func TestDirReadDirAll(t *testing.T) {
|
|||
|
||||
node, err = vfs.Stat("")
|
||||
require.NoError(t, err)
|
||||
dir = node.(*Dir)
|
||||
root := node.(*Dir)
|
||||
|
||||
checkListing(t, dir, []string{"dir,0,true"})
|
||||
checkListing(t, root, []string{"dir,0,true"})
|
||||
|
||||
node, err = vfs.Stat("dir/subdir")
|
||||
require.NoError(t, err)
|
||||
dir = node.(*Dir)
|
||||
subdir := node.(*Dir)
|
||||
|
||||
checkListing(t, dir, []string{"file3,16,false"})
|
||||
checkListing(t, subdir, []string{"file3,16,false"})
|
||||
|
||||
t.Run("Virtual", func(t *testing.T) {
|
||||
node, err := vfs.Stat("dir")
|
||||
require.NoError(t, err)
|
||||
dir := node.(*Dir)
|
||||
|
||||
// Add some virtual entries and check what happens
|
||||
dir.AddVirtual("virtualFile", 17, false)
|
||||
dir.AddVirtual("virtualDir", 0, true)
|
||||
|
@ -298,6 +294,11 @@ func TestDirReadDirAll(t *testing.T) {
|
|||
|
||||
checkListing(t, dir, []string{"file1,14,false", "virtualDir,0,true", "virtualFile,17,false"})
|
||||
|
||||
// Check that forgetting the root doesn't invalidate the virtual entries
|
||||
root.ForgetAll()
|
||||
|
||||
checkListing(t, dir, []string{"file1,14,false", "virtualDir,0,true", "virtualFile,17,false"})
|
||||
|
||||
// Now action the deletes and uploads
|
||||
_ = r.WriteObject(context.Background(), "dir/virtualFile", "virtualFile contents", t1)
|
||||
_ = r.WriteObject(context.Background(), "dir/virtualDir/testFile", "testFile contents", t1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue