MongoDB record encryption fix.

Ylian Saint-Hilaire committed Jan 11, 2021 at 13:37 UTC e5694aeb9314ea4d9d34f94f57af55fe260411d1
1 file changed +4 -7
db.js
+4 -7
@@ -40,10 +40,8 @@ module.exports.CreateDB = function (parent, func) {
40 obj.pluginsActive = ((parent.config) && (parent.config.settings) && (parent.config.settings.plugins != null) && (parent.config.settings.plugins != false) && ((typeof parent.config.settings.plugins != 'object') || (parent.config.settings.plugins.enabled != false)));
41
42 // MongoDB bulk write state
43 - /*
43 obj.filePendingGet = null;
44 obj.filePendingGets = null;
46 - */
45 obj.filePendingSet = false;
46 obj.filePendingSets = null;
47 obj.filePendingCb = null;
@@ -1059,6 +1057,8 @@ module.exports.CreateDB = function (parent, func) {
1057 if (func != null) { if (obj.filePendingCb == null) { obj.filePendingCb = [ func ]; } else { obj.filePendingCb.push(func); } }
1058 }
1059 };
1060 +
1061 + /*
1062 obj.Get = function (id, func) {
1063 if (arguments.length > 2) {
1064 var parms = [func];
@@ -1081,8 +1081,8 @@ module.exports.CreateDB = function (parent, func) {
1081 });
1082 }
1083 };
1084 + */
1085
1085 - /*
1086 obj.Get = function (id, func) { // Fast Get operation using a bulk find() to reduce round trips to the database.
1087 // Encode arguments into return function if any are present.
1088 var func2 = func;
@@ -1109,7 +1109,6 @@ module.exports.CreateDB = function (parent, func) {
1109 if (obj.filePendingGet[id] == null) { obj.filePendingGet[id] = [func2]; } else { obj.filePendingGet[id].push(func2); }
1110 }
1111 };
1112 - */
1112
1113 obj.GetAll = function (func) { obj.file.find({}).toArray(function (err, docs) { func(err, performTypedRecordDecrypt(docs)); }); };
1114 obj.GetHash = function (id, func) { obj.file.find({ _id: id }).project({ _id: 0, hash: 1 }).toArray(function (err, docs) { func(err, performTypedRecordDecrypt(docs)); }); };
@@ -1490,7 +1489,6 @@ module.exports.CreateDB = function (parent, func) {
1489 }
1490 }
1491
1493 - /*
1492 // MongoDB pending bulk read operation, perform fast bulk document reads.
1493 function fileBulkReadCompleted(err, docs) {
1494 // Send out callbacks with results
@@ -1498,7 +1496,7 @@ module.exports.CreateDB = function (parent, func) {
1496 for (var i in docs) {
1497 if (docs[i].links != null) { docs[i] = common.unEscapeLinksFieldName(docs[i]); }
1498 const id = docs[i]._id;
1501 - if (obj.filePendingGets[id] != null) { for (var j in obj.filePendingGets[id]) { obj.filePendingGets[id][j](err, [ docs[i] ]); } delete obj.filePendingGets[id]; }
1499 + if (obj.filePendingGets[id] != null) { for (var j in obj.filePendingGets[id]) { obj.filePendingGets[id][j](err, performTypedRecordDecrypt([docs[i]])); } delete obj.filePendingGets[id]; }
1500 }
1501 }
1502
@@ -1514,7 +1512,6 @@ module.exports.CreateDB = function (parent, func) {
1512 obj.file.find({ _id: { $in: findlist } }).toArray(fileBulkReadCompleted);
1513 }
1514 }
1517 - */
1515
1516 // MongoDB pending bulk write operation, perform fast bulk document replacement.
1517 function fileBulkWriteCompleted() {