diff --git a/libs/monitor.js b/libs/monitor.js index b2e3fc05..3d8c62dd 100644 --- a/libs/monitor.js +++ b/libs/monitor.js @@ -15,6 +15,13 @@ const { } = require('worker_threads'); const { copyObject, createQueue, queryStringToObject, createQueryStringFromObject } = require('./common.js') module.exports = function(s,config,lang){ + const isMasterNode = ( + ( + config.childNodes.enabled === true && + config.childNodes.mode === 'master' + ) || + config.childNodes.enabled === false + ); const { probeMonitor, getStreamInfoFromProbe, @@ -1589,13 +1596,7 @@ module.exports = function(s,config,lang){ status: wantedStatus, code: wantedStatusCode, }) - if( - ( - config.childNodes.enabled === true && - config.childNodes.mode === 'master' - ) || - config.childNodes.enabled === false - ){ + if(isMasterNode){ setTimeout(() => { scanForOrphanedVideos({ ke: e.ke, @@ -1604,7 +1605,7 @@ module.exports = function(s,config,lang){ forceCheck: true, checkMax: 2 }) - },2000) + },2000) } clearTimeout(s.group[e.ke].activeMonitors[e.id].onMonitorStartTimer) s.onMonitorStopExtensions.forEach(function(extender){ diff --git a/libs/video/utils.js b/libs/video/utils.js index 49830148..c36d21c5 100644 --- a/libs/video/utils.js +++ b/libs/video/utils.js @@ -1,13 +1,6 @@ const fs = require('fs') const { spawn } = require('child_process') module.exports = (s,config,lang) => { - const isMasterNode = ( - ( - config.childNodes.enabled === true && - config.childNodes.mode === 'master' - ) || - config.childNodes.enabled === false - ); // orphanedVideoCheck : new function const checkIfVideoIsOrphaned = (monitor,videosDirectory,filename) => { const response = {ok: true} @@ -47,7 +40,7 @@ module.exports = (s,config,lang) => { }) }) } - let scanForOrphanedVideos = (monitor,options) => { + const scanForOrphanedVideos = (monitor,options) => { // const options = { // checkMax: 2 // } @@ -122,11 +115,6 @@ module.exports = (s,config,lang) => { } }) } - if(!isMasterNode){ - scanForOrphanedVideos = async () => { - return {ok: true, orphanedFilesCount: 0} - } - } // orphanedVideoCheck : old function const orphanedVideoCheck = (monitor,checkMax,callback,forceCheck) => { var finish = function(orphanedFilesCount){