Compare commits
No commits in common. "a0d4ca7fbc941b19f0850e0a036d8d0618ee12cd" and "bef886d8ad046a016b40a71e1d26276a02a98b28" have entirely different histories.
a0d4ca7fbc
...
bef886d8ad
|
@ -356,9 +356,7 @@ class MongoClientInterface {
|
|||
_id: vObjName,
|
||||
},
|
||||
update: {
|
||||
_id: vObjName,
|
||||
tag: MongoUtils.generateNewTag(),
|
||||
value: objVal,
|
||||
_id: vObjName, value: objVal,
|
||||
},
|
||||
upsert: true,
|
||||
},
|
||||
|
@ -380,9 +378,7 @@ class MongoClientInterface {
|
|||
],
|
||||
},
|
||||
update: {
|
||||
_id: objName,
|
||||
tag: MongoUtils.generateNewTag(),
|
||||
value: objVal,
|
||||
_id: objName, value: objVal,
|
||||
},
|
||||
upsert: true,
|
||||
},
|
||||
|
@ -423,18 +419,14 @@ class MongoClientInterface {
|
|||
const versionId = generateVersionId(this.replicationGroupId);
|
||||
// eslint-disable-next-line
|
||||
objVal.versionId = versionId;
|
||||
const query = { _id: objName };
|
||||
const update = {
|
||||
c.update({
|
||||
_id: objName,
|
||||
}, {
|
||||
_id: objName,
|
||||
tag: MongoUtils.generateNewTag(),
|
||||
value: objVal,
|
||||
};
|
||||
const options = { upsert: true };
|
||||
if (params.cond && params.cond.tag) {
|
||||
query.tag = params.cond.tag;
|
||||
options.upsert = false;
|
||||
}
|
||||
c.update(query, update, options, err => {
|
||||
}, {
|
||||
upsert: true,
|
||||
}, err => {
|
||||
if (err) {
|
||||
log.error(
|
||||
'putObjectVerCase2: error putting object version',
|
||||
|
@ -459,19 +451,12 @@ class MongoClientInterface {
|
|||
// eslint-disable-next-line
|
||||
objVal.versionId = params.versionId;
|
||||
const vObjName = formatVersionKey(objName, params.versionId);
|
||||
const query = { _id: objName };
|
||||
if (params.cond && params.cond.tag) {
|
||||
query.tag = params.cond.tag;
|
||||
}
|
||||
c.findOne(query, (err, checkObj) => {
|
||||
c.findOne({ _id: objName }, (err, checkObj) => {
|
||||
if (err) {
|
||||
log.error('putObjectVerCase3: mongoDB error finding object');
|
||||
return cb(errors.InternalError);
|
||||
}
|
||||
const objUpsert = !checkObj;
|
||||
if (objUpsert && params.cond && params.cond.tag) {
|
||||
return cb();
|
||||
}
|
||||
c.bulkWrite([{
|
||||
updateOne: {
|
||||
filter: {
|
||||
|
@ -480,7 +465,6 @@ class MongoClientInterface {
|
|||
update: {
|
||||
$set: {
|
||||
_id: vObjName,
|
||||
tag: MongoUtils.generateNewTag(),
|
||||
value: objVal,
|
||||
},
|
||||
},
|
||||
|
@ -496,7 +480,6 @@ class MongoClientInterface {
|
|||
update: {
|
||||
$set: {
|
||||
_id: objName,
|
||||
tag: MongoUtils.generateNewTag(),
|
||||
value: objVal,
|
||||
},
|
||||
},
|
||||
|
@ -529,18 +512,14 @@ class MongoClientInterface {
|
|||
* Put object when versioning is not enabled
|
||||
*/
|
||||
putObjectNoVer(c, bucketName, objName, objVal, params, log, cb) {
|
||||
const query = { _id: objName };
|
||||
const update = {
|
||||
c.update({
|
||||
_id: objName,
|
||||
}, {
|
||||
_id: objName,
|
||||
tag: MongoUtils.generateNewTag(),
|
||||
value: objVal,
|
||||
};
|
||||
const options = { upsert: true };
|
||||
if (params.cond && params.cond.tag) {
|
||||
query.tag = params.cond.tag;
|
||||
options.upsert = false;
|
||||
}
|
||||
c.update(query, update, options, err => {
|
||||
}, {
|
||||
upsert: true,
|
||||
}, err => {
|
||||
if (err) {
|
||||
log.error(
|
||||
'putObjectNoVer: error putting obect with no versioning',
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
const uuid = require('uuid/v4');
|
||||
|
||||
function escape(obj) {
|
||||
return JSON.parse(JSON.stringify(obj).
|
||||
|
@ -28,8 +27,4 @@ function unserialize(objMD) {
|
|||
}
|
||||
}
|
||||
|
||||
function generateNewTag() {
|
||||
return uuid();
|
||||
}
|
||||
|
||||
module.exports = { escape, unescape, serialize, unserialize, generateNewTag };
|
||||
module.exports = { escape, unescape, serialize, unserialize };
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue