Update db.js

The Slash before the additional parameters inside the mongoDB connectionstring gave us great headaches. After the AutoBackup initiated it immediately fails as it couldn't find the database with a trailing slash. Our connectionstring contains information for the local MongoDB User and the authentication DB. The String looks as follows (user and password have been omitted): mongodb://{{user}}:{{password}}@localhost:27017/meshcentral?authSource=admin&compressors=zlib&gssapiServiceName=mongodb

Fabian G committed May 19, 2021 at 10:15 UTC 5cc23d960ed1ba5962ce17fd8401dfd3e5f2eefb
1 file changed +2 -2
db.js
+2 -2
@@ -1656,7 +1656,7 @@ module.exports.CreateDB = function (parent, func) {
1656 var mongoDumpPath = 'mongodump';
1657 if (parent.config.settings.autobackup && parent.config.settings.autobackup.mongodumppath) { mongoDumpPath = parent.config.settings.autobackup.mongodumppath; }
1658 var cmd = '"' + mongoDumpPath + '"';
1659 - if (dburl) { cmd = '\"' + mongoDumpPath + '\" --uri=\"' + dburl.replace('?', '/?') + '\"'; }
1659 + if (dburl) { cmd = '\"' + mongoDumpPath + '\" --uri=\"' + dburl + '\"'; }
1660 cmd += (parent.platform == 'win32') ? ' --archive=\"nul\"' : ' --archive=\"/dev/null\"';
1661 const child_process = require('child_process');
1662 child_process.exec(cmd, { cwd: backupPath }, function (error, stdout, stderr) {
@@ -1834,7 +1834,7 @@ module.exports.CreateDB = function (parent, func) {
1834 if (parent.config.settings.autobackup && parent.config.settings.autobackup.mongodumppath) { mongoDumpPath = parent.config.settings.autobackup.mongodumppath; }
1835 const child_process = require('child_process');
1836 var cmd = '\"' + mongoDumpPath + '\" --db=\"' + dbname + '\" --archive=\"' + newBackupPath + '.archive\"';
1837 - if (dburl) { cmd = '\"' + mongoDumpPath + '\" --uri=\"' + dburl.replace('?', '/?') + '\" --archive=\"' + newBackupPath + '.archive\"'; }
1837 + if (dburl) { cmd = '\"' + mongoDumpPath + '\" --uri=\"' + dburl + '\" --archive=\"' + newBackupPath + '.archive\"'; }
1838 var backupProcess = child_process.exec(cmd, { cwd: backupPath }, function (error, stdout, stderr) {
1839 try {
1840 var mongoDumpSuccess = true;