Skip to content

Commit e8368d5

Browse files
varg1714ForSourceCodeAnalysis
authored andcommitted
fix(fs): clear cache after directory rename to ensure consistency (OpenListTeam#1193)
Clear cache after renaming the directory.
1 parent 79d683b commit e8368d5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/op/fs.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,12 +493,18 @@ func Rename(ctx context.Context, storage driver.Driver, srcPath, dstName string,
493493
updateCacheObj(storage, srcDirPath, srcRawObj, model.WrapObjName(newObj))
494494
} else if !utils.IsBool(lazyCache...) {
495495
DeleteCache(storage, srcDirPath)
496+
if srcRawObj.IsDir() {
497+
ClearCache(storage, srcPath)
498+
}
496499
}
497500
}
498501
case driver.Rename:
499502
err = s.Rename(ctx, srcObj, dstName)
500503
if err == nil && !utils.IsBool(lazyCache...) {
501504
DeleteCache(storage, srcDirPath)
505+
if srcRawObj.IsDir() {
506+
ClearCache(storage, srcPath)
507+
}
502508
}
503509
default:
504510
return errs.NotImplement

0 commit comments

Comments
 (0)