Skip to content

Commit 53ffaa7

Browse files
committed
Fix recursive dir cache invalidation bug
1 parent 24a7c13 commit 53ffaa7

File tree

7 files changed

+492
-652
lines changed

7 files changed

+492
-652
lines changed

fs/cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func (cache *FileSystemCache) RemoveDirEntryCache(path string, recursive bool) {
160160
func (cache *FileSystemCache) RemoveParentDirEntryCache(path string, recursive bool) {
161161
if cache.config.InvalidateParentEntryCacheImmediately {
162162
parentPath := util.GetIRODSPathDirname(path)
163-
cache.RemoveDirEntryCache(parentPath, true)
163+
cache.RemoveDirEntryCache(parentPath, recursive)
164164
}
165165
}
166166

fs/fs_cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func (fs *FileSystem) invalidateCacheForFileCreate(path string) {
191191
fs.cache.RemoveNegativeEntryCache(path)
192192

193193
// parent dir's entry also changes
194-
fs.cache.RemoveParentDirEntryCache(path, true)
194+
fs.cache.RemoveParentDirEntryCache(path, false)
195195
// parent dir's dir entry also changes
196196
parentPath := util.GetIRODSPathDirname(path)
197197
parentDirEntries := fs.cache.GetDirCache(parentPath)

test/testcases/dummy.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"testing"
88

99
"github.com/cyverse/go-irodsclient/test/server"
10+
"github.com/rs/xid"
1011
"golang.org/x/xerrors"
1112
)
1213

@@ -79,9 +80,11 @@ func CreateSampleFilesAndDirs(t *testing.T, server *server.IRODSTestServer, dest
7980

8081
// create random files
8182
baseRecord := 100
83+
id := xid.New().String()
84+
8285
for i := 0; i < numFiles; i++ {
8386
filesize := int64((i + 1) * 62 * baseRecord)
84-
filename := fmt.Sprintf("test_file_%d.bin", filesize)
87+
filename := fmt.Sprintf("test_file_%s_%d.bin", id, filesize)
8588

8689
tempPath, err := CreateLocalTestFile(t, filename, filesize)
8790
if err != nil {
@@ -104,7 +107,7 @@ func CreateSampleFilesAndDirs(t *testing.T, server *server.IRODSTestServer, dest
104107

105108
// create random directories
106109
for i := 0; i < numDirs; i++ {
107-
dirname := fmt.Sprintf("test_dir_%d", i)
110+
dirname := fmt.Sprintf("test_dir_%s_%d", id, i)
108111

109112
irodsPath := dest + "/" + dirname
110113
err = fs.MakeDir(irodsPath, true)

0 commit comments

Comments
 (0)