Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
williamlardier committed Oct 3, 2023
1 parent 5fd675a commit 65c9f80
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/storage/metadata/mongoclient/MongoClientInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -1045,19 +1045,20 @@ class MongoClientInterface {
* gets object metadata for a list of objects
* @param {String} bucketName bucket name
* @param {Array} objects array of objects
* @param {Number} maxKeys max number of keys to return
* @param {Object} log logger
* @param {Function} callback callback
* @return {undefined}
*/
getObjects(bucketName, objects, log, callback) {
getObjects(bucketName, objects, maxKeys = 1000, log, callback) {
const c = this.getCollection(bucketName);
let vFormat = null;
if (!Array.isArray(objects)) {
return callback(errors.InternalError.customizeDescription('objects must be an array'));
}
// We do not accept more than 1000 keys in a single request
if (objects.length > 1000) {
return callback(errors.InternalError.customizeDescription('cannot get more than 1000 objects'));
// We do not accept more than maxKeys keys in a single request
if (objects.length > maxKeys) {
return callback(errors.InternalError.customizeDescription(`cannot get more than ${maxKeys} objects`));
}
// Function to process each document
const processDoc = (doc, objName, params, key, cb) => {
Expand Down Expand Up @@ -1103,7 +1104,7 @@ class MongoClientInterface {
{ 'value.deleted': { $exists: false } },
{ 'value.deleted': { $eq: false } },
],
}).toArray().then(docs => {
}).batchSize(maxKeys).toArray().then(docs => {
// Create a Map to quickly find docs by their keys
const docByKey = new Map(docs.map(doc => [doc._id, doc]));
// Process each document using associated context (objName, params)
Expand Down

0 comments on commit 65c9f80

Please sign in to comment.