From d1e3eda1f138bd184e517a8263796926383521a1 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Sun, 6 Jan 2019 20:32:12 -0800 Subject: [PATCH] Fixed unlink() required callback in NodeJS v10. --- meshcentral.js | 6 ------ meshuser.js | 4 ++-- package.json | 2 +- webserver.js | 2 +- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/meshcentral.js b/meshcentral.js index 7b35fe5c..03620f3d 100644 --- a/meshcentral.js +++ b/meshcentral.js @@ -580,12 +580,6 @@ function CreateMeshCentralServer(config, args) { if (restoreFile) { obj.debug(1, 'Server stopped, updating settings: ' + restoreFile); console.log('Updating settings folder...'); - /* - var unzip = require('unzip'); - var rs = obj.fs.createReadStream(restoreFile); - rs.on('end', () => { setTimeout(function () { fs.unlinkSync(restoreFile); process.exit(123); }, 500); }); - rs.pipe(unzip.Extract({ path: obj.datapath })); - */ var yauzl = require("yauzl"); yauzl.open(restoreFile, { lazyEntries: true }, function (err, zipfile) { diff --git a/meshuser.js b/meshuser.js index 259c941c..ba754041 100644 --- a/meshuser.js +++ b/meshuser.js @@ -384,7 +384,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use for (i in command.names) { var s = obj.path.join(scpath, command.names[i]), d = obj.path.join(path, command.names[i]); sendUpdate = false; - copyFile(s, d, function (op) { if (op != null) { obj.fs.unlink(op, function () { obj.parent.parent.DispatchEvent([user._id], obj, 'updatefiles'); }); } else { obj.parent.parent.DispatchEvent([user._id], obj, 'updatefiles'); } }, ((command.fileop == 'move') ? s : null)); + copyFile(s, d, function (op) { if (op != null) { obj.fs.unlink(op, function (err) { obj.parent.parent.DispatchEvent([user._id], obj, 'updatefiles'); }); } else { obj.parent.parent.DispatchEvent([user._id], obj, 'updatefiles'); } }, ((command.fileop == 'move') ? s : null)); } } @@ -724,7 +724,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use { // Clear the server error log if ((user.siteadmin & 16) == 0) break; - obj.parent.parent.fs.unlink(obj.parent.parent.getConfigFilePath('mesherrors.txt')); + obj.parent.parent.fs.unlink(obj.parent.parent.getConfigFilePath('mesherrors.txt'), function (err) { }); break; } case 'createmesh': diff --git a/package.json b/package.json index d8a5a174..be63fa5c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.2.5-v", + "version": "0.2.5-w", "keywords": [ "Remote Management", "Intel AMT", diff --git a/webserver.js b/webserver.js index 2cc0ff7a..4fda0d19 100644 --- a/webserver.js +++ b/webserver.js @@ -1125,7 +1125,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { obj.parent.DispatchEvent([user._id], obj, 'updatefiles'); // Fire an event causing this user to update this files }); } else { - try { obj.fs.unlink(file.path); } catch (e) { } + try { obj.fs.unlink(file.path, function (err) { }); } catch (e) { } } } }