diff --git a/meshuser.js b/meshuser.js index 8d817960..4c43f42c 100644 --- a/meshuser.js +++ b/meshuser.js @@ -120,19 +120,29 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use } else return null; var rootfolder = meshpath[0], rootfoldersplit = rootfolder.split('/'), domainx = 'domain'; if (rootfoldersplit[1].length > 0) domainx = 'domain-' + rootfoldersplit[1]; - var path = parent.path.join(parent.filespath, domainx, rootfoldersplit[0] + "-" + rootfoldersplit[2]); + var path = parent.path.join(parent.filespath, domainx, rootfoldersplit[0] + '-' + rootfoldersplit[2]); for (var i = 1; i < meshpath.length; i++) { if (common.IsFilenameValid(meshpath[i]) == false) { path = null; break; } path += ("/" + meshpath[i]); } return path; } - // TODO: Replace this with something better? + // Copy a file using the best technique available function copyFile(src, dest, func, tag) { - var ss = fs.createReadStream(src), ds = fs.createWriteStream(dest); - ss.pipe(ds); - ds.ss = ss; - if (arguments.length == 3 && typeof arguments[2] === 'function') { ds.on('close', arguments[2]); } - else if (arguments.length == 4 && typeof arguments[3] === 'function') { ds.on('close', arguments[3]); } - ds.on('close', function () { func(tag); }); + if (fs.copyFile) { + // NodeJS v8.5 and higher + fs.copyFile(src, dest, function (err) { func(tag); }) + } else { + // Older NodeJS + try { + var ss = fs.createReadStream(src), ds = fs.createWriteStream(dest); + ss.on('error', function () { func(tag); }); + ds.on('error', function () { func(tag); }); + ss.pipe(ds); + ds.ss = ss; + if (arguments.length == 3 && typeof arguments[2] === 'function') { ds.on('close', arguments[2]); } + else if (arguments.length == 4 && typeof arguments[3] === 'function') { ds.on('close', arguments[3]); } + ds.on('close', function () { func(tag); }); + } catch (ex) { } + } } // Route a command to a target node @@ -607,9 +617,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use if ((command.fileop == 'createfolder') && (common.IsFilenameValid(command.newfolder) == true)) { // Create a new folder - try { fs.mkdirSync(path + "/" + command.newfolder); } catch (e) { - try { fs.mkdirSync(path); } catch (e) { } - try { fs.mkdirSync(path + "/" + command.newfolder); } catch (e) { } + try { fs.mkdirSync(path + '/' + command.newfolder); } catch (ex) { + try { fs.mkdirSync(path); } catch (ex) { } + try { fs.mkdirSync(path + '/' + command.newfolder); } catch (ex) { } } } else if (command.fileop == 'delete') { @@ -619,9 +629,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use if (common.IsFilenameValid(command.delfiles[i]) == true) { var fullpath = parent.path.join(path, command.delfiles[i]); if (command.rec == true) { - deleteFolderRecursive(fullpath); // TODO, make this an async function + try { deleteFolderRecursive(fullpath); } catch (ex) { } // TODO, make this an async function } else { - try { fs.rmdirSync(fullpath); } catch (e) { try { fs.unlinkSync(fullpath); } catch (e) { } } + try { fs.rmdirSync(fullpath); } catch (ex) { try { fs.unlinkSync(fullpath); } catch (xe) { } } } } } diff --git a/package.json b/package.json index f65aa6eb..19765991 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.4.3-q", + "version": "0.4.3-r", "keywords": [ "Remote Management", "Intel AMT", diff --git a/public/styles/messenger.css b/public/styles/messenger.css index acc3cecc..74f419d2 100644 --- a/public/styles/messenger.css +++ b/public/styles/messenger.css @@ -3,10 +3,10 @@ border: none; margin: 2px; margin-top: 3px; - float: right; border-radius: 3px; height: 32px; width: 32px; + float: right; } .topButton:hover { diff --git a/views/default-min.handlebars b/views/default-min.handlebars index 2667d095..ac69b0ef 100644 --- a/views/default-min.handlebars +++ b/views/default-min.handlebars @@ -3524,7 +3524,7 @@ if (xxdialogMode) return; var url = '/messenger?id=meshmessenger/' + encodeURIComponent(currentNode._id) + '/' + encodeURIComponent(userinfo._id) + '&title=' + currentNode.name; if ((authCookie != null) && (authCookie != '')) { url += '&auth=' + authCookie; } - window.open(url, 'meshmessenger:' + currentNode._id); + window.open(url, 'meshmessenger:' + currentNode._id, 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=560'); meshserver.send({ action: 'meshmessenger', nodeid: decodeURIComponent(currentNode._id) }); } @@ -6740,12 +6740,12 @@ var h = ''; if (f.t < 3 || f.t == 4) { var right = (f.t == 1 || f.t == 4)?p5getQuotabar(f):'', title = ''; - h = '