mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-26 23:25:53 -05:00
Fixed EXDEV error on rename.
This commit is contained in:
parent
b2e3ee056e
commit
c137eda4ac
10
common.js
10
common.js
@ -259,3 +259,13 @@ module.exports.translationsToJson = function(t) {
|
|||||||
arr2.sort(function (a, b) { if (a.en > b.en) return 1; if (a.en < b.en) return -1; return 0; });
|
arr2.sort(function (a, b) { if (a.en > b.en) return 1; if (a.en < b.en) return -1; return 0; });
|
||||||
return JSON.stringify({ strings: arr2 }, null, ' ');
|
return JSON.stringify({ strings: arr2 }, null, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.copyFile = function(source, target, cb) {
|
||||||
|
var cbCalled = false, rd = fs.createReadStream(source);
|
||||||
|
rd.on('error', function (err) { done(err); });
|
||||||
|
var wr = fs.createWriteStream(target);
|
||||||
|
wr.on('error', function (err) { done(err); });
|
||||||
|
wr.on('close', function (ex) { done(); });
|
||||||
|
rd.pipe(wr);
|
||||||
|
function done(err) { if (!cbCalled) { cb(err); cbCalled = true; } }
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "meshcentral",
|
"name": "meshcentral",
|
||||||
"version": "0.4.8-g",
|
"version": "0.4.8-h",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Remote Management",
|
"Remote Management",
|
||||||
"Intel AMT",
|
"Intel AMT",
|
||||||
|
12
webserver.js
12
webserver.js
@ -2261,9 +2261,19 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
|||||||
try { obj.fs.mkdirSync(obj.parent.path.join(obj.parent.filespath, domainx)); } catch (e) { }
|
try { obj.fs.mkdirSync(obj.parent.path.join(obj.parent.filespath, domainx)); } catch (e) { }
|
||||||
try { obj.fs.mkdirSync(xfile.fullpath); } catch (e) { }
|
try { obj.fs.mkdirSync(xfile.fullpath); } catch (e) { }
|
||||||
|
|
||||||
obj.fs.rename(file.path, fpath, function () {
|
// Rename the file
|
||||||
|
obj.fs.rename(file.path, fpath, function (err) {
|
||||||
|
if (err && (err.code === 'EXDEV') && fs.copyFile) {
|
||||||
|
// On some Linux, the rename will fail with a "EXDEV" error, do a copy+unlink instead.
|
||||||
|
obj.common.copyFile(file.path, fpath, function (err) {
|
||||||
|
obj.fs.unlink(file.path, function (err) {
|
||||||
obj.parent.DispatchEvent([user._id], obj, 'updatefiles'); // Fire an event causing this user to update this files
|
obj.parent.DispatchEvent([user._id], obj, 'updatefiles'); // Fire an event causing this user to update this files
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
obj.parent.DispatchEvent([user._id], obj, 'updatefiles'); // Fire an event causing this user to update this files
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
try { obj.fs.unlink(file.path, function (err) { }); } catch (e) { }
|
try { obj.fs.unlink(file.path, function (err) { }); } catch (e) { }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user