Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
williamlardier committed Oct 24, 2024
1 parent cff219b commit d497379
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions lib/storage/metadata/mongoclient/MongoClientInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const CONCURRENT_CURSORS = 10;
const initialInstanceID = process.env.INITIAL_INSTANCE_ID;

let uidCounter = 0;
let cachedBucketAttributes = null;

const BUCKET_VERSIONS = require('../../../versioning/constants')
.VersioningConstants.BucketVersioningKeyFormat;
Expand Down Expand Up @@ -352,24 +353,47 @@ class MongoClientInterface {
}

getBucketAndObject(bucketName, objName, params, log, cb) {

Check warning on line 355 in lib/storage/metadata/mongoclient/MongoClientInterface.js

View workflow job for this annotation

GitHub Actions / test

Expected to return a value at the end of method 'getBucketAndObject'
// Check if the bucket attributes are already cached
if (cachedBucketAttributes) {
log.info('Using cached bucket attributes');
return this.getObject(bucketName, objName, params, log, (err, obj) => {
if (err) {
if (err.is.NoSuchKey) {
return cb(null, {
bucket: BucketInfo.fromObj(cachedBucketAttributes).serialize(),
});
}
log.error('getObject: error getting object', { error: err.message });
return cb(err);
}
return cb(null, {
bucket: BucketInfo.fromObj(cachedBucketAttributes).serialize(),
obj: JSON.stringify(obj),
});
});
}

Check failure on line 375 in lib/storage/metadata/mongoclient/MongoClientInterface.js

View workflow job for this annotation

GitHub Actions / test

Trailing spaces not allowed
// If no cached attributes, call getBucketAttributes and cache the result
this.getBucketAttributes(bucketName, log, (err, bucket) => {
if (err) {
log.error(
'getBucketAttributes: error getting bucket attributes',
{ error: err.message });
{ error: err.message }

Check failure on line 381 in lib/storage/metadata/mongoclient/MongoClientInterface.js

View workflow job for this annotation

GitHub Actions / test

Missing trailing comma
);
return cb(err);
}

Check failure on line 385 in lib/storage/metadata/mongoclient/MongoClientInterface.js

View workflow job for this annotation

GitHub Actions / test

Trailing spaces not allowed
// Cache the bucket attributes
cachedBucketAttributes = bucket;

Check failure on line 388 in lib/storage/metadata/mongoclient/MongoClientInterface.js

View workflow job for this annotation

GitHub Actions / test

Trailing spaces not allowed
this.getObject(bucketName, objName, params, log, (err, obj) => {
if (err) {
if (err.is.NoSuchKey) {
return cb(null,
{
bucket:
BucketInfo.fromObj(bucket).serialize(),
});
return cb(null, {
bucket: BucketInfo.fromObj(bucket).serialize(),
});
}
log.error('getObject: error getting object',
{ error: err.message });
log.error('getObject: error getting object', { error: err.message });
return cb(err);
}
return cb(null, {
Expand Down

0 comments on commit d497379

Please sign in to comment.