filer store: fix nil for mongodb (#6886)

fix https://github.com/seaweedfs/seaweedfs/issues/6885
This commit is contained in:
Chris Lu
2025-06-16 14:21:05 -07:00
committed by GitHub
parent 06a3140142
commit 5d8a391b95

View File

@@ -234,14 +234,22 @@ func (store *MongodbStore) ListDirectoryPrefixedEntries(ctx context.Context, dir
"directory": string(dirPath), "directory": string(dirPath),
} }
nameQuery := bson.M{}
if len(prefix) > 0 { if len(prefix) > 0 {
where["name"].(bson.M)["$regex"] = "^" + regexp.QuoteMeta(prefix) nameQuery["$regex"] = "^" + regexp.QuoteMeta(prefix)
} }
if includeStartFile { if len(startFileName) > 0 {
where["name"].(bson.M)["$gte"] = startFileName if includeStartFile {
} else { nameQuery["$gte"] = startFileName
where["name"].(bson.M)["$gt"] = startFileName } else {
nameQuery["$gt"] = startFileName
}
}
if len(nameQuery) > 0 {
where["name"] = nameQuery
} }
optLimit := int64(limit) optLimit := int64(limit)