diff options
| author | Chris Lu <chris.lu@gmail.com> | 2019-04-01 17:03:04 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2019-04-01 17:03:04 -0700 |
| commit | beaa2bd71aea9df7fd6d92c0a7da7d97015be7ef (patch) | |
| tree | b79500ef87935b9869e6ca6f3bbcbef880e0b6f7 /weed | |
| parent | 78b9db34d5a3b491221a8ad6f4fd7eab0498e3f9 (diff) | |
| download | seaweedfs-beaa2bd71aea9df7fd6d92c0a7da7d97015be7ef.tar.xz seaweedfs-beaa2bd71aea9df7fd6d92c0a7da7d97015be7ef.zip | |
weed filer: properly delete cached directory entry
fix https://github.com/chrislusf/seaweedfs/issues/910
Diffstat (limited to 'weed')
| -rw-r--r-- | weed/filer2/filer.go | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/weed/filer2/filer.go b/weed/filer2/filer.go index 06c26abb4..faf9b9bca 100644 --- a/weed/filer2/filer.go +++ b/weed/filer2/filer.go @@ -217,29 +217,32 @@ func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p FullPath, isRecurs if err != nil { return fmt.Errorf("list folder %s: %v", p, err) } + if len(entries) == 0 { break - } else { - if isRecursive { - for _, sub := range entries { - lastFileName = sub.Name() - f.DeleteEntryMetaAndData(ctx, sub.FullPath, isRecursive, shouldDeleteChunks) - limit-- - if limit <= 0 { - break - } + } + + if isRecursive { + for _, sub := range entries { + lastFileName = sub.Name() + err = f.DeleteEntryMetaAndData(ctx, sub.FullPath, isRecursive, shouldDeleteChunks) + if err != nil { + return err } - } else { - if len(entries) > 0 { - return fmt.Errorf("folder %s is not empty", p) + limit-- + if limit <= 0 { + break } } - f.cacheDelDirectory(string(p)) - if len(entries) < 1024 { - break - } + } + + if len(entries) < 1024 { + break } } + + f.cacheDelDirectory(string(p)) + } if shouldDeleteChunks { @@ -264,6 +267,11 @@ func (f *Filer) ListDirectoryEntries(ctx context.Context, p FullPath, startFileN } func (f *Filer) cacheDelDirectory(dirpath string) { + + if dirpath == "/" { + return + } + if f.directoryCache == nil { return } @@ -272,6 +280,7 @@ func (f *Filer) cacheDelDirectory(dirpath string) { } func (f *Filer) cacheGetDirectory(dirpath string) *Entry { + if f.directoryCache == nil { return nil } |
