aboutsummaryrefslogtreecommitdiff
path: root/weed/filer/filer_search.go
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2025-12-04 10:44:31 -0800
committerGitHub <noreply@github.com>2025-12-04 10:44:31 -0800
commit66e2d9bca1397489309e0754f7c059c398934012 (patch)
tree0e326035a43aa360c894aaeec2b9bddcb3aa63ce /weed/filer/filer_search.go
parent49ed42b367914ac4f3e2853e698e8fc05ddac24e (diff)
parent8d110b29ddfd9b9cdb504a4380106b2b287155ca (diff)
downloadseaweedfs-origin/feature/tus-protocol.tar.xz
seaweedfs-origin/feature/tus-protocol.zip
Merge branch 'master' into feature/tus-protocolorigin/feature/tus-protocol
Diffstat (limited to 'weed/filer/filer_search.go')
-rw-r--r--weed/filer/filer_search.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/weed/filer/filer_search.go b/weed/filer/filer_search.go
index 294fc0e7f..e6366e82f 100644
--- a/weed/filer/filer_search.go
+++ b/weed/filer/filer_search.go
@@ -41,6 +41,19 @@ func (f *Filer) ListDirectoryEntries(ctx context.Context, p util.FullPath, start
return entries, hasMore, err
}
+// CountDirectoryEntries counts entries in a directory up to limit
+func (f *Filer) CountDirectoryEntries(ctx context.Context, p util.FullPath, limit int) (count int, err error) {
+ entries, hasMore, err := f.ListDirectoryEntries(ctx, p, "", false, int64(limit), "", "", "")
+ if err != nil {
+ return 0, err
+ }
+ count = len(entries)
+ if hasMore {
+ count = limit // At least this many
+ }
+ return count, nil
+}
+
// For now, prefix and namePattern are mutually exclusive
func (f *Filer) StreamListDirectoryEntries(ctx context.Context, p util.FullPath, startFileName string, inclusive bool, limit int64, prefix string, namePattern string, namePatternExclude string, eachEntryFunc ListEachEntryFunc) (lastFileName string, err error) {
if strings.HasSuffix(string(p), "/") && len(p) > 1 {