SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
paginate through large directories
Chris Lu97c942b5eefc
diff --git a/weed/pb/filer_pb/filer_client.go b/weed/pb/filer_pb/filer_client.goindex 96a716d5b2..9fe5fd146e 100644--- a/weed/pb/filer_pb/filer_client.go+++ b/weed/pb/filer_pb/filer_client.go@@ -5,7 +5,6 @@ import ("errors""fmt""io"- "math""os""strings""time"@@ -61,14 +60,32 @@ type EachEntryFunciton func(entry *Entry, isLast bool) errorfunc ReadDirAllEntries(filerClient FilerClient, fullDirPath util.FullPath, prefix string, fn EachEntryFunciton) (err error) {- return doList(filerClient, fullDirPath, prefix, fn, "", false, math.MaxUint32)+ var counter uint32+ var startFrom string+ var counterFunc = func(entry *Entry, isLast bool) error {+ counter+++ startFrom = entry.Name+ return fn(entry, isLast)+ }+ var paginationLimit uint32 = 10000++ if err = doList(filerClient, fullDirPath, prefix, counterFunc, "", false, paginationLimit); err != nil {+ return err+ }++ for counter == paginationLimit {+ counter = 0+ if err = doList(filerClient, fullDirPath, prefix, counterFunc, startFrom, false, paginationLimit); err != nil {+ return err+ }+ }++ return nil}func List(filerClient FilerClient, parentDirectoryPath, prefix string, fn EachEntryFunciton, startFrom string, inclusive bool, limit uint32) (err error) {-return doList(filerClient, util.FullPath(parentDirectoryPath), prefix, fn, startFrom, inclusive, limit)-}func doList(filerClient FilerClient, fullDirPath util.FullPath, prefix string, fn EachEntryFunciton, startFrom string, inclusive bool, limit uint32) (err error) {