Skip to content

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.

mongodb: ensure closing cursor

chrislu98cce6a15022
diff --git a/weed/filer/mongodb/mongodb_store.go b/weed/filer/mongodb/mongodb_store.go
index 6935be1ab4..7f2da7047f 100644
--- a/weed/filer/mongodb/mongodb_store.go
+++ b/weed/filer/mongodb/mongodb_store.go
@@ -199,9 +199,13 @@ func (store *MongodbStore) ListDirectoryEntries(ctx context.Context, dirPath uti
for cur.Next(ctx) {
var data Model
- err := cur.Decode(&data)
- if err != nil && err != mongo.ErrNoDocuments {
- return lastFileName, err
+ err = cur.Decode(&data)
+ if err == mongo.ErrNoDocuments {
+ err = nil
+ break
+ }
+ if err != nil {
+ break
}
entry := &filer.Entry{