mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Added details to context menu, recordings bug fixes.
This commit is contained in:
parent
efc378be6b
commit
3470c81b34
4 changed files with 86 additions and 53 deletions
52
meshrelay.js
52
meshrelay.js
|
@ -527,29 +527,37 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
|||
|
||||
// If there is a recording quota, remove any old recordings if needed
|
||||
function cleanUpRecordings() {
|
||||
if (domain.sessionrecording && ((typeof domain.sessionrecording.maxrecordings == 'number') || (typeof domain.sessionrecording.maxrecordingsizemegabytes == 'number'))) {
|
||||
var recPath = null, fs = require('fs');
|
||||
if (domain.sessionrecording.filepath) { recPath = domain.sessionrecording.filepath; } else { recPath = parent.parent.recordpath; }
|
||||
fs.readdir(recPath, function (err, files) {
|
||||
if ((err != null) || (files == null)) return;
|
||||
var recfiles = [];
|
||||
for (var i in files) {
|
||||
if (files[i].endsWith('.mcrec')) {
|
||||
var j = files[i].indexOf('-');
|
||||
if (j > 0) { recfiles.push({ n: files[i], r: files[i].substring(j + 1), s: fs.statSync(parent.parent.path.join(recPath, files[i])).size }); }
|
||||
if ((parent.cleanUpRecordingsActive !== true) && domain.sessionrecording && ((typeof domain.sessionrecording.maxrecordings == 'number') || (typeof domain.sessionrecording.maxrecordingsizemegabytes == 'number'))) {
|
||||
parent.cleanUpRecordingsActive = true;
|
||||
setTimeout(function () {
|
||||
var recPath = null, fs = require('fs');
|
||||
if (domain.sessionrecording.filepath) { recPath = domain.sessionrecording.filepath; } else { recPath = parent.parent.recordpath; }
|
||||
fs.readdir(recPath, function (err, files) {
|
||||
if ((err != null) || (files == null)) { delete parent.cleanUpRecordingsActive; return; }
|
||||
var recfiles = [];
|
||||
for (var i in files) {
|
||||
if (files[i].endsWith('.mcrec')) {
|
||||
var j = files[i].indexOf('-');
|
||||
if (j > 0) {
|
||||
var size = null;
|
||||
try { size = fs.statSync(parent.parent.path.join(recPath, files[i])).size } catch (ex) { }
|
||||
if (size != null) { recfiles.push({ n: files[i], r: files[i].substring(j + 1), s: size }); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
recfiles.sort(function (a, b) { if (a.r < b.r) return 1; if (a.r > b.r) return -1; return 0; });
|
||||
var totalFiles = 0, totalSize = 0;
|
||||
for (var i in recfiles) {
|
||||
var overQuota = false;
|
||||
if ((typeof domain.sessionrecording.maxrecordings == 'number') && (totalFiles >= domain.sessionrecording.maxrecordings)) { overQuota = true; }
|
||||
else if ((typeof domain.sessionrecording.maxrecordingsizemegabytes == 'number') && (totalSize >= (domain.sessionrecording.maxrecordingsizemegabytes * 1048576))) { overQuota = true; }
|
||||
if (overQuota) { fs.unlinkSync(parent.parent.path.join(recPath, recfiles[i].n)); }
|
||||
totalFiles++;
|
||||
totalSize += recfiles[i].s;
|
||||
}
|
||||
});
|
||||
recfiles.sort(function (a, b) { if (a.r < b.r) return 1; if (a.r > b.r) return -1; return 0; });
|
||||
var totalFiles = 0, totalSize = 0;
|
||||
for (var i in recfiles) {
|
||||
var overQuota = false;
|
||||
if ((typeof domain.sessionrecording.maxrecordings == 'number') && (totalFiles >= domain.sessionrecording.maxrecordings)) { overQuota = true; }
|
||||
else if ((typeof domain.sessionrecording.maxrecordingsizemegabytes == 'number') && (totalSize >= (domain.sessionrecording.maxrecordingsizemegabytes * 1048576))) { overQuota = true; }
|
||||
if (overQuota) { fs.unlinkSync(parent.parent.path.join(recPath, recfiles[i].n)); }
|
||||
totalFiles++;
|
||||
totalSize += recfiles[i].s;
|
||||
}
|
||||
delete parent.cleanUpRecordingsActive;
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue