diff --git a/meshdesktopmultiplex.js b/meshdesktopmultiplex.js index d0cee1ee..0e2ca9b7 100644 --- a/meshdesktopmultiplex.js +++ b/meshdesktopmultiplex.js @@ -720,28 +720,32 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) { // 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) { recfiles.push({ n: files[i], r: files[i].substring(j + 1), s: fs.statSync(parent.parent.path.join(recPath, files[i])).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; + }); }); } } diff --git a/meshrelay.js b/meshrelay.js index a23deb95..00c687c4 100644 --- a/meshrelay.js +++ b/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); } } diff --git a/translate/translate.json b/translate/translate.json index 8cf545f4..e98e27c9 100644 --- a/translate/translate.json +++ b/translate/translate.json @@ -8017,7 +8017,8 @@ "ru": "Детали", "zh-chs": "細節", "xloc": [ - "default.handlebars->container->topbar->1->1->MainSubMenuSpan->MainSubMenu->1->0->MainDevInfo" + "default.handlebars->container->topbar->1->1->MainSubMenuSpan->MainSubMenu->1->0->MainDevInfo", + "default.handlebars->contextMenu->cxdetails" ] }, { @@ -20105,7 +20106,8 @@ "zh-chs": "外掛程式", "xloc": [ "default.handlebars->container->topbar->1->1->MainSubMenuSpan->MainSubMenu->1->0->MainDevPlugins", - "default.handlebars->container->topbar->1->1->ServerSubMenuSpan->ServerSubMenu->1->0->ServerPlugins" + "default.handlebars->container->topbar->1->1->ServerSubMenuSpan->ServerSubMenu->1->0->ServerPlugins", + "default.handlebars->contextMenu->cxplugins" ] }, { diff --git a/views/default.handlebars b/views/default.handlebars index d2bb64d2..90994789 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -44,9 +44,11 @@