aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-02-18 23:36:10 -0800
committerchrislu <chris.lu@gmail.com>2022-02-18 23:36:10 -0800
commitb3594278c90cd2da58fcf44f64178bcfd148e7e1 (patch)
treee5df00bbf7957ba63c00623b836a3072eea84bc7
parent61811dc2f1fd1391a9e0ed6af063a80e38b9ec5a (diff)
downloadseaweedfs-b3594278c90cd2da58fcf44f64178bcfd148e7e1.tar.xz
seaweedfs-b3594278c90cd2da58fcf44f64178bcfd148e7e1.zip
optimize a bit
-rw-r--r--weed/filer/filerstore_wrapper.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/weed/filer/filerstore_wrapper.go b/weed/filer/filerstore_wrapper.go
index ca531dc3a..2a7cd5889 100644
--- a/weed/filer/filerstore_wrapper.go
+++ b/weed/filer/filerstore_wrapper.go
@@ -285,8 +285,10 @@ func (fsw *FilerStoreWrapper) prefixFilterEntries(ctx context.Context, dirPath u
count := int64(0)
for count < limit && len(notPrefixed) > 0 {
+ var isLastItemHasPrefix bool
for _, entry := range notPrefixed {
if strings.HasPrefix(entry.Name(), prefix) {
+ isLastItemHasPrefix = true
count++
if !eachEntryFunc(entry) {
return
@@ -294,9 +296,11 @@ func (fsw *FilerStoreWrapper) prefixFilterEntries(ctx context.Context, dirPath u
if count >= limit {
break
}
+ } else {
+ isLastItemHasPrefix = false
}
}
- if count < limit {
+ if count < limit && isLastItemHasPrefix {
notPrefixed = notPrefixed[:0]
lastFileName, err = actualStore.ListDirectoryEntries(ctx, dirPath, lastFileName, false, limit, func(entry *Entry) bool {
notPrefixed = append(notPrefixed, entry)