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 8e830fe commit cff219b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/storage/metadata/MetadataWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,20 @@ class MetadataWrapper {
});
}

updateObjectMD(bucketName, objName, objVersion, update, params, log, cb) {
log.debug('updating object in metadata');
this.client.updateObject(bucketName, objName, objVersion, update, params, log,
err => {
if (err) {
log.debug('error from metadata', { implName: this.implName,
error: err });
return cb(err);
}
log.debug('object successfully updated in metadata');
return cb();
});
}

putObjectMD(bucketName, objName, objVal, params, log, cb) {
log.debug('putting object in metadata');
const value = typeof objVal.getValue === 'function' ?
Expand Down
21 changes: 21 additions & 0 deletions lib/storage/metadata/mongoclient/MongoClientInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,27 @@ class MongoClientInterface {
return this.putObjectNoVer;
}

updateObject(bucketName, objName, versionId, updateOp, params, log, cb) {
const c = this.getCollection(bucketName);
const filter = {
_id: null,
};
const update = {
$set: updateOp,
};
if (versionId) {
const versionKey = formatVersionKey(objName, versionId, params.vFormat);
filter._id = versionKey;
} else {
const key = formatMasterKey(objName, params.vFormat);
filter._id = key;
}
return c.updateOne(filter, update).then(() => cb()).catch(err => {
log.error('updateObject: error updating object', { error: err.message });
return cb(errors.InternalError);
});
}

/**
* puts object metadata in bucket
* @param {String} bucketName bucket name
Expand Down

0 comments on commit cff219b

Please sign in to comment.