fix(fs): clear cache after directory rename to ensure consistency (#1193)

Clear cache after renaming the directory.
This commit is contained in:
walloo
2025-09-01 18:47:54 +08:00
committed by GitHub
parent 8188fb2d7d
commit 89f35170b3

View File

@ -486,12 +486,18 @@ func Rename(ctx context.Context, storage driver.Driver, srcPath, dstName string,
updateCacheObj(storage, srcDirPath, srcRawObj, model.WrapObjName(newObj)) updateCacheObj(storage, srcDirPath, srcRawObj, model.WrapObjName(newObj))
} else if !utils.IsBool(lazyCache...) { } else if !utils.IsBool(lazyCache...) {
DeleteCache(storage, srcDirPath) DeleteCache(storage, srcDirPath)
if srcRawObj.IsDir() {
ClearCache(storage, srcPath)
}
} }
} }
case driver.Rename: case driver.Rename:
err = s.Rename(ctx, srcObj, dstName) err = s.Rename(ctx, srcObj, dstName)
if err == nil && !utils.IsBool(lazyCache...) { if err == nil && !utils.IsBool(lazyCache...) {
DeleteCache(storage, srcDirPath) DeleteCache(storage, srcDirPath)
if srcRawObj.IsDir() {
ClearCache(storage, srcPath)
}
} }
default: default:
return errs.NotImplement return errs.NotImplement