Compare commits

..

No commits in common. "3610a6807d7fa1770e7be69ad7540fa80902aa31" and "d994e2ae607f9a8a228ea5215f35e9141ab5a8c6" have entirely different histories.

3 changed files with 0 additions and 196 deletions

View File

@ -356,7 +356,6 @@ class MultipleBackendGateway {
getDiskUsage(config, reqUids, callback) { getDiskUsage(config, reqUids, callback) {
new DataFileBackend(config).getDiskUsage(config, reqUids, callback); new DataFileBackend(config).getDiskUsage(config, reqUids, callback);
} }
} }
module.exports = MultipleBackendGateway; module.exports = MultipleBackendGateway;

View File

@ -356,12 +356,6 @@ class MetadataWrapper {
notifyBucketChange(cb) { notifyBucketChange(cb) {
bucketNotificationHook = cb; bucketNotificationHook = cb;
} }
close() {
if (this.client.close === 'function') {
this.client.close();
}
}
} }
module.exports = MetadataWrapper; module.exports = MetadataWrapper;

View File

@ -14,7 +14,6 @@ const async = require('async');
const { EventEmitter } = require('events'); const { EventEmitter } = require('events');
const constants = require('../../../constants'); const constants = require('../../../constants');
const { reshapeExceptionError } = require('../../../errorUtils');
const errors = require('../../../errors'); const errors = require('../../../errors');
const BucketInfo = require('../../../models/BucketInfo'); const BucketInfo = require('../../../models/BucketInfo');
@ -63,45 +62,6 @@ function inc(str) {
const VID_SEPPLUS = inc(VID_SEP); const VID_SEPPLUS = inc(VID_SEP);
const MONGODB_QUERY_OPERATORS = [
'$eq',
'$gt',
'$gte',
'$in',
'$lt',
'$lte',
'$ne',
'$nin',
'$and',
'$not',
'$nor',
'$or',
'$exists',
'$type',
'$expr',
'$jsonSchema',
'$mod',
'$regex',
'$text',
'$where',
'$geoIntersects',
'$geoWithin',
'$near',
'$nearSphere',
'$all',
'$elemMatch',
'$size',
'$bitsAllClear',
'$bitsAllSet',
'$bitsAnyClear',
'$bitsAnySet',
'$comment',
'$',
'$elemMatch',
'$meta',
'$slice',
];
function generatePHDVersion(versionId) { function generatePHDVersion(versionId) {
return { return {
isPHD: true, isPHD: true,
@ -662,10 +622,6 @@ class MongoClientInterface {
return this.putObjectVerCase4(c, bucketName, objName, objVal, return this.putObjectVerCase4(c, bucketName, objName, objVal,
params, log, cb); params, log, cb);
} }
if (params && params.query) {
return this.putObjectNoVerConditional(
c, bucketName, objName, objVal, params, log, cb);
}
return this.putObjectNoVer(c, bucketName, objName, objVal, return this.putObjectNoVer(c, bucketName, objName, objVal,
params, log, cb); params, log, cb);
} }
@ -959,10 +915,6 @@ class MongoClientInterface {
return this.deleteObjectVer(c, bucketName, objName, return this.deleteObjectVer(c, bucketName, objName,
params, log, cb); params, log, cb);
} }
if (params && params.query) {
return this.deleteObjectNoVerConditional(
c, bucketName, objName, params, log, cb);
}
return this.deleteObjectNoVer(c, bucketName, objName, return this.deleteObjectNoVer(c, bucketName, objName,
params, log, cb); params, log, cb);
} }
@ -1682,147 +1634,6 @@ class MongoClientInterface {
return cb(null, doc.map(i => i.value)); return cb(null, doc.map(i => i.value));
}); });
} }
/*
* converts regular js object into mongodb usable filters
* Example: with starting prefix ""
* {
* hello: {
* world: {
* $eq: 42
* }
* }
* }
* is will be parsed as
* {
* "hello.world": { $eq: 42 }
* }
*
*/
_genMongoQuery(depth, prefix, object, query) {
/* eslint-disable no-param-reassign */
if (depth > 10) {
throw errors.InternalError;
}
if (typeof query !== 'object' ||
query === null ||
query === undefined) {
object[prefix] = query;
return;
}
const fields = Object.keys(query);
if (fields.some(f => MONGODB_QUERY_OPERATORS.includes(f))) {
object[prefix] = query;
} else {
fields.forEach(f => this._genMongoQuery(depth + 1,
`${prefix}.${f}`,
object, query[f])
);
}
return;
/* eslint-enable no-param-reassign */
}
_getFilter(objName, query) {
const filter = { _id: objName };
this._genMongoQuery(0, 'value', filter, query);
return filter;
}
/*
* delete an object that matches a given query object
*/
deleteObjectNoVerConditional(c, bucketName, objName, params, log, cb) {
const method = 'deleteObjectNoVerConditional';
let filter;
try {
filter = this._getFilter(objName, params.query);
} catch (err) {
log.error('error creating mongodb filter', {
error: reshapeExceptionError(err),
});
return cb(errors.InternalError);
}
return c.findOneAndDelete(filter, (err, res) => {
if (err) {
log.error('error occurred when attempting to delete object', {
method,
error: err.message,
});
return cb(errors.InternalError);
}
if (res.ok !== 1) {
log.error('failed to delete object', {
method,
error: err.message,
});
return cb(errors.InternalError);
}
/*
* unable to find an object that matches the query
*/
if (!res.value) {
log.debug('unable to find target object to delete', {
method,
filter,
});
return cb(errors.NoSuchKey);
}
return cb();
});
}
/*
* update an object that matches a given query. If one cannot be found,
* a new object will be inserted
*/
putObjectNoVerConditional(c, bucketName, objName, objVal, params, log, cb) {
const method = 'putObjectNoVerConditional';
let filter;
try {
filter = this._getFilter(objName, params.query);
} catch (err) {
log.error('error creating mongodb filter', {
error: reshapeExceptionError(err),
});
return cb(errors.InternalError);
}
return c.findOneAndUpdate(filter, {
$set: {
_id: objName,
value: objVal,
},
}, {
upsert: true,
}, (err, res) => {
if (err) {
log.error('error occurred when attempting update object', {
method,
error: err,
});
return cb(errors.InternalError);
}
if (res.ok !== 1) {
log.error('failed to update object', {
method,
error: err.message,
});
return cb(errors.InternalError);
}
if (!res.value) {
log.debug('object not found...inserting object', {
method,
filter,
});
return cb();
}
log.debug('Object found...updating object', {
method,
filter,
});
return cb();
});
}
} }
module.exports = MongoClientInterface; module.exports = MongoClientInterface;