aboutsummaryrefslogtreecommitdiff
path: root/weed/filer/filer_search.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-01-16 19:52:15 -0800
committerChris Lu <chris.lu@gmail.com>2021-01-16 19:52:15 -0800
commit09f49d1c0440a55041c60643480d4159a9af3f0e (patch)
tree38147fde36cec948faa314a009b9eebc770c488b /weed/filer/filer_search.go
parenta4063a5437f0554962bcdadefc96c9131f8c0395 (diff)
downloadseaweedfs-09f49d1c0440a55041c60643480d4159a9af3f0e.tar.xz
seaweedfs-09f49d1c0440a55041c60643480d4159a9af3f0e.zip
refactoring
Diffstat (limited to 'weed/filer/filer_search.go')
-rw-r--r--weed/filer/filer_search.go19
1 files changed, 1 insertions, 18 deletions
diff --git a/weed/filer/filer_search.go b/weed/filer/filer_search.go
index 8c9688ceb..0a14d3756 100644
--- a/weed/filer/filer_search.go
+++ b/weed/filer/filer_search.go
@@ -21,29 +21,12 @@ func splitPattern(pattern string) (prefix string, restPattern string) {
// For now, prefix and namePattern are mutually exclusive
func (f *Filer) ListDirectoryEntries(ctx context.Context, p util.FullPath, startFileName string, inclusive bool, limit int64, prefix string, namePattern string) (entries []*Entry, hasMore bool, err error) {
- if strings.HasSuffix(string(p), "/") && len(p) > 1 {
- p = p[0 : len(p)-1]
- }
-
- prefixInNamePattern, restNamePattern := splitPattern(namePattern)
- if prefixInNamePattern != "" {
- prefix = prefixInNamePattern
- }
- var missedCount int64
- var lastFileName string
- missedCount, lastFileName, err = f.doListPatternMatchedEntries(ctx, p, startFileName, inclusive, limit+1, prefix, restNamePattern, func(entry *Entry) bool {
+ _, err = f.StreamListDirectoryEntries(ctx, p, startFileName, inclusive, limit+1, prefix, namePattern, func(entry *Entry) bool {
entries = append(entries, entry)
return true
})
- for missedCount > 0 && err == nil {
- missedCount, lastFileName, err = f.doListPatternMatchedEntries(ctx, p, lastFileName, false, missedCount+1, prefix, restNamePattern, func(entry *Entry) bool {
- entries = append(entries, entry)
- return true
- })
- }
-
hasMore = int64(len(entries)) >= limit+1
if hasMore {
entries = entries[:limit]