From 1c10b9c0232512b98e9c1dac1d900a02c3054c5a Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Sun, 21 Jun 2020 13:59:49 -0700 Subject: [PATCH] Fixed issue with server files. --- meshuser.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/meshuser.js b/meshuser.js index 6f09eb78..3bd831cb 100644 --- a/meshuser.js +++ b/meshuser.js @@ -734,19 +734,22 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use } catch (ex) { } } } - else if ((command.fileop == 'rename') && (common.IsFilenameValid(command.oldname) == true) && (common.IsFilenameValid(command.newname) == true)) { + else if ((command.fileop == 'rename') && (common.IsFilenameValid(command.oldname) === true) && (common.IsFilenameValid(command.newname) === true)) { // Rename try { fs.renameSync(path + '/' + command.oldname, path + '/' + command.newname); } catch (e) { } } else if ((command.fileop == 'copy') || (command.fileop == 'move')) { + // Copy or move of one or many files if (common.validateArray(command.names, 1) == false) return; var scpath = meshPathToRealPath(command.scpath, user); // This will also check access rights if (scpath == null) break; // TODO: Check quota if this is a copy!!!!!!!!!!!!!!!! for (i in command.names) { - var s = parent.path.join(scpath, command.names[i]), d = parent.path.join(path, command.names[i]); - sendUpdate = false; - copyFile(s, d, function (op) { if (op != null) { fs.unlink(op, function (err) { parent.parent.DispatchEvent([user._id], obj, 'updatefiles'); }); } else { parent.parent.DispatchEvent([user._id], obj, 'updatefiles'); } }, ((command.fileop == 'move') ? s : null)); + if (common.IsFilenameValid(command.names[i]) === true) { + var s = parent.path.join(scpath, command.names[i]), d = parent.path.join(path, command.names[i]); + sendUpdate = false; + copyFile(s, d, function (op) { if (op != null) { fs.unlink(op, function (err) { parent.parent.DispatchEvent([user._id], obj, 'updatefiles'); }); } else { parent.parent.DispatchEvent([user._id], obj, 'updatefiles'); } }, ((command.fileop == 'move') ? s : null)); + } } }