Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

bugfix:delete Directory cache when filer2 delete Directory

聂鹏c523bc4f07d8
diff --git a/weed/filer2/filer.go b/weed/filer2/filer.go
index 53de5bea3a..2d7eaf097c 100644
--- a/weed/filer2/filer.go
+++ b/weed/filer2/filer.go
@@ -137,6 +137,7 @@ func (f *Filer) DeleteEntryMetaAndData(p FullPath, shouldDeleteChunks bool) (err
if len(entries) > 0 {
return fmt.Errorf("folder %s is not empty", p)
}
+ f.cacheDelDirectory(string(p))
}
if shouldDeleteChunks {
@@ -153,6 +154,14 @@ func (f *Filer) ListDirectoryEntries(p FullPath, startFileName string, inclusive
return f.store.ListDirectoryEntries(p, startFileName, inclusive, limit)
}
+func (f *Filer) cacheDelDirectory(dirpath string) {
+ if f.directoryCache == nil {
+ return
+ }
+ f.directoryCache.Delete(dirpath)
+ return
+}
+
func (f *Filer) cacheGetDirectory(dirpath string) *Entry {
if f.directoryCache == nil {
return nil