create folder first before copy/move #5704

This commit is contained in:
Simon Smith 2024-01-31 15:02:50 +00:00 committed by GitHub
parent cdab553800
commit 4648dbeb26
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 0 deletions

View File

@ -906,6 +906,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (common.IsFilenameValid(command.names[i]) === true) { if (common.IsFilenameValid(command.names[i]) === true) {
var s = parent.path.join(scpath, command.names[i]), d = parent.path.join(path, command.names[i]); var s = parent.path.join(scpath, command.names[i]), d = parent.path.join(path, command.names[i]);
sendUpdate = false; sendUpdate = false;
try { fs.mkdirSync(path); } catch (ex) { } // try to create folder first incase folder is missing
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)); 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));
} }
} }