Fixed path object in meshuser.js
Ylian Saint-Hilaire committed
Mar 20, 2019 at 09:53 UTC
1a5b3ba596ddce83d25a032d4e0d47d5f65f49db
2 files changed
+11
-11
meshuser.js
+10
-10
@@ -81,7 +81,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
81
} else return null;
82
var rootfolder = meshpath[0], rootfoldersplit = rootfolder.split('/'), domainx = 'domain';
83
if (rootfoldersplit[1].length > 0) domainx = 'domain-' + rootfoldersplit[1];
84
- var path = path.join(parent.filespath, domainx, rootfoldersplit[0] + "-" + rootfoldersplit[2]);
84
+ var path = parent.path.join(parent.filespath, domainx, rootfoldersplit[0] + "-" + rootfoldersplit[2]);
85
for (var i = 1; i < meshpath.length; i++) { if (common.IsFilenameValid(meshpath[i]) == false) { path = null; break; } path += ("/" + meshpath[i]); }
86
return path;
87
}
@@ -419,7 +419,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
419
if (common.validateArray(command.delfiles, 1) == false) return;
420
for (i in command.delfiles) {
421
if (common.IsFilenameValid(command.delfiles[i]) == true) {
422
- var fullpath = path.join(path, command.delfiles[i]);
422
+ var fullpath = parent.path.join(path, command.delfiles[i]);
423
if (command.rec == true) {
424
deleteFolderRecursive(fullpath); // TODO, make this an async function
425
} else {
@@ -448,7 +448,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
448
if (scpath == null) break;
449
// TODO: Check quota if this is a copy!!!!!!!!!!!!!!!!
450
for (i in command.names) {
451
- var s = path.join(scpath, command.names[i]), d = path.join(path, command.names[i]);
451
+ var s = parent.path.join(scpath, command.names[i]), d = parent.path.join(path, command.names[i]);
452
sendUpdate = false;
453
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));
454
}
@@ -2109,7 +2109,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2109
function deleteFolderRecursive(path) {
2110
if (fs.existsSync(path)) {
2111
fs.readdirSync(path).forEach(function (file, index) {
2112
- var curPath = path.join(path, file);;
2112
+ var curPath = parent.path.join(path, file);;
2113
if (fs.lstatSync(curPath).isDirectory()) { // recurse
2114
deleteFolderRecursive(curPath);
2115
} else { // delete file
@@ -2134,15 +2134,15 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2134
2135
// Read all files recursively
2136
try {
2137
- files.filetree.f[user._id].f = readFilesRec(path.join(parent.filespath, domainx + "/user-" + usersplit[2]));
2137
+ files.filetree.f[user._id].f = readFilesRec(parent.path.join(parent.filespath, domainx + "/user-" + usersplit[2]));
2138
} catch (e) {
2139
// TODO: We may want to fake this file structure until it's needed.
2140
// Got an error, try to create all the folders and try again...
2141
try { fs.mkdirSync(parent.filespath); } catch (e) { }
2142
- try { fs.mkdirSync(path.join(parent.filespath, domainx)); } catch (e) { }
2143
- try { fs.mkdirSync(path.join(parent.filespath, domainx + "/user-" + usersplit[2])); } catch (e) { }
2144
- try { fs.mkdirSync(path.join(parent.filespath, domainx + "/user-" + usersplit[2] + "/Public")); } catch (e) { }
2145
- try { files.filetree.f[user._id].f = readFilesRec(path.join(parent.filespath, domainx + "/user-" + usersplit[2])); } catch (e) { }
2142
+ try { fs.mkdirSync(parent.path.join(parent.filespath, domainx)); } catch (e) { }
2143
+ try { fs.mkdirSync(parent.path.join(parent.filespath, domainx + "/user-" + usersplit[2])); } catch (e) { }
2144
+ try { fs.mkdirSync(parent.path.join(parent.filespath, domainx + "/user-" + usersplit[2] + "/Public")); } catch (e) { }
2145
+ try { files.filetree.f[user._id].f = readFilesRec(parent.path.join(parent.filespath, domainx + "/user-" + usersplit[2])); } catch (e) { }
2146
}
2147
2148
// Add files for each mesh
@@ -2156,7 +2156,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2156
2157
// Read all files recursively
2158
try {
2159
- files.filetree.f[mesh._id].f = readFilesRec(path.join(parent.filespath, domainx + "/mesh-" + meshsplit[2]));
2159
+ files.filetree.f[mesh._id].f = readFilesRec(parent.path.join(parent.filespath, domainx + "/mesh-" + meshsplit[2]));
2160
} catch (e) {
2161
files.filetree.f[mesh._id].f = {}; // Got an error, return empty folder. We will create the folder only when needed.
2162
}
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.3.0-q",
3
+ "version": "0.3.0-r",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",