Return of sizePurgeQueue
- you can also say return of the Q (hehe)merge-requests/33/head
parent
b1c27f8359
commit
69f7543c79
|
@ -524,7 +524,7 @@ module.exports = function(s,config,lang){
|
|||
fs.mkdirSync(e.dir);
|
||||
}
|
||||
}
|
||||
fs.chmod(e.dir,0o777,function(err){
|
||||
exec('chmod -R 777 '+e.dir,function(err){
|
||||
|
||||
})
|
||||
//set the temporary files directory
|
||||
|
@ -542,7 +542,7 @@ module.exports = function(s,config,lang){
|
|||
}
|
||||
}
|
||||
setStreamDir()
|
||||
fs.chmod(e.sdir,0o777,function(err){
|
||||
exec('chmod -R 777 '+e.sdir,function(err){
|
||||
|
||||
})
|
||||
return setStreamDir
|
||||
|
|
19
libs/user.js
19
libs/user.js
|
@ -50,6 +50,7 @@ module.exports = function(s,config){
|
|||
if(!s.group[e.ke].fileBin){s.group[e.ke].fileBin={}};
|
||||
if(!s.group[e.ke].users){s.group[e.ke].users={}}
|
||||
if(!s.group[e.ke].dashcamUsers){s.group[e.ke].dashcamUsers={}}
|
||||
if(!s.group[e.ke].sizePurgeQueue){s.group[e.ke].sizePurgeQueue=[]}
|
||||
if(!e.limit||e.limit===''){e.limit=10000}else{e.limit=parseFloat(e.limit)}
|
||||
//save global space limit for group key (mb)
|
||||
s.group[e.ke].sizeLimit=e.limit;
|
||||
|
@ -151,10 +152,23 @@ module.exports = function(s,config){
|
|||
})
|
||||
s.group[e.ke].diskUsedEmitter.on('purge',function(){
|
||||
if(config.cron.deleteOverMax === true){
|
||||
//set queue processor
|
||||
s.group[e.ke].sizePurgeQueue.push(1)
|
||||
if(s.group[e.ke].sizePurging !== true){
|
||||
s.group[e.ke].sizePurging = true
|
||||
var finish = function(){
|
||||
//remove value just used from queue
|
||||
s.group[e.ke].sizePurgeQueue.shift()
|
||||
//do next one
|
||||
if(s.group[e.ke].sizePurgeQueue.length > 0){
|
||||
checkQueue()
|
||||
}else{
|
||||
s.group[e.ke].sizePurging=false
|
||||
s.sendDiskUsedAmountToClients(e)
|
||||
}
|
||||
}
|
||||
var checkQueue=function(){
|
||||
//get first in queue
|
||||
var currentPurge = s.group[e.ke].sizePurgeQueue[0]
|
||||
var deleteVideos = function(){
|
||||
//run purge command
|
||||
if(s.group[e.ke].usedSpace > (s.group[e.ke].sizeLimit*config.cron.deleteOverMaxOffset)){
|
||||
|
@ -193,6 +207,9 @@ module.exports = function(s,config){
|
|||
}
|
||||
}
|
||||
deleteVideos()
|
||||
}
|
||||
checkQueue()
|
||||
}
|
||||
}else{
|
||||
s.sendDiskUsedAmountToClients(e)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue