From 3d7ae2081abd75d99098203b985356f3a9d64de2 Mon Sep 17 00:00:00 2001 From: Moe Date: Fri, 5 Oct 2018 15:49:44 -0700 Subject: [PATCH] fix Delete Motionless bug+ - fo' real this time --- libs/monitor.js | 39 ++++++++++++++++++++------------------- libs/videos.js | 6 ++++-- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/libs/monitor.js b/libs/monitor.js index b1a3345e..b13faf69 100644 --- a/libs/monitor.js +++ b/libs/monitor.js @@ -1173,26 +1173,27 @@ module.exports = function(s,config,lang){ var filename = d.split('.')[0]+'.'+e.ext s.insertCompletedVideo(e,{ file : filename - }) - s.log(e,{type:lang['Video Finished'],msg:{filename:d}}) - if( - e.details.detector === '1' && - s.group[e.ke].mon[e.id].started === 1 && - e.details && - e.details.detector_record_method === 'del'&& - e.details.detector_delete_motionless_videos === '1'&& - s.group[e.ke].mon[e.id].detector_motion_count === 0 - ){ - if(e.details.loglevel !== 'quiet'){ - s.log(e,{type:lang['Delete Motionless Video'],msg:filename}); + },function(err){ + s.log(e,{type:lang['Video Finished'],msg:{filename:d}}) + if( + e.details.detector === '1' && + s.group[e.ke].mon[e.id].started === 1 && + e.details && + e.details.detector_record_method === 'del'&& + e.details.detector_delete_motionless_videos === '1'&& + s.group[e.ke].mon[e.id].detector_motion_count === 0 + ){ + if(e.details.loglevel !== 'quiet'){ + s.log(e,{type:lang['Delete Motionless Video'],msg:filename}) + } + s.deleteVideo({ + filename : filename, + ke : e.ke, + id : e.id + }) } - s.deleteVideo({ - filename : filename, - ke : e.ke, - id : e.id - }) - } - s.group[e.ke].mon[e.id].detector_motion_count = 0 + s.group[e.ke].mon[e.id].detector_motion_count = 0 + }) resetRecordingCheck() return; break; diff --git a/libs/videos.js b/libs/videos.js index 6d6fa03b..63b70533 100644 --- a/libs/videos.js +++ b/libs/videos.js @@ -51,7 +51,7 @@ module.exports = function(s,config,lang){ s.insertCompletedVideoExtensions.push(callback) } //on video completion - s.insertCompletedVideo = function(e,k){ + s.insertCompletedVideo = function(e,k,callback){ //e = video object //k = temporary values if(!e.id && e.mid)e.id = e.mid @@ -154,7 +154,9 @@ module.exports = function(s,config,lang){ k.filesize, k.endTime, ] - s.sqlQuery('INSERT INTO Videos (mid,ke,time,ext,status,details,size,end) VALUES (?,?,?,?,?,?,?,?)',save) + s.sqlQuery('INSERT INTO Videos (mid,ke,time,ext,status,details,size,end) VALUES (?,?,?,?,?,?,?,?)',save,function(err){ + if(callback)callback(err) + }) //purge over max s.purgeDiskForGroup(e) //send new diskUsage values