mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-19 17:54:37 +08:00
optimize a bit
This commit is contained in:
@@ -285,8 +285,10 @@ func (fsw *FilerStoreWrapper) prefixFilterEntries(ctx context.Context, dirPath u
|
|||||||
|
|
||||||
count := int64(0)
|
count := int64(0)
|
||||||
for count < limit && len(notPrefixed) > 0 {
|
for count < limit && len(notPrefixed) > 0 {
|
||||||
|
var isLastItemHasPrefix bool
|
||||||
for _, entry := range notPrefixed {
|
for _, entry := range notPrefixed {
|
||||||
if strings.HasPrefix(entry.Name(), prefix) {
|
if strings.HasPrefix(entry.Name(), prefix) {
|
||||||
|
isLastItemHasPrefix = true
|
||||||
count++
|
count++
|
||||||
if !eachEntryFunc(entry) {
|
if !eachEntryFunc(entry) {
|
||||||
return
|
return
|
||||||
@@ -294,9 +296,11 @@ func (fsw *FilerStoreWrapper) prefixFilterEntries(ctx context.Context, dirPath u
|
|||||||
if count >= limit {
|
if count >= limit {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
isLastItemHasPrefix = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if count < limit {
|
if count < limit && isLastItemHasPrefix {
|
||||||
notPrefixed = notPrefixed[:0]
|
notPrefixed = notPrefixed[:0]
|
||||||
lastFileName, err = actualStore.ListDirectoryEntries(ctx, dirPath, lastFileName, false, limit, func(entry *Entry) bool {
|
lastFileName, err = actualStore.ListDirectoryEntries(ctx, dirPath, lastFileName, false, limit, func(entry *Entry) bool {
|
||||||
notPrefixed = append(notPrefixed, entry)
|
notPrefixed = append(notPrefixed, entry)
|
||||||
|
Reference in New Issue
Block a user