Fix broken timelapse frame write

axis-lock
Moe 2023-05-09 12:38:58 -07:00
parent b08ec2ef98
commit 870f8e1bc2
1 changed files with 25 additions and 20 deletions

View File

@ -1122,7 +1122,8 @@ module.exports = (s,config,lang) => {
}
if(e.details.record_timelapse === '1'){
var timelapseRecordingDirectory = s.getTimelapseFrameDirectory(e)
activeMonitor.spawn.stdio[7].on('data', async function(data){
activeMonitor.spawn.stdio[7].on('data', function(data){
try{
var fileStream = activeMonitor.recordTimelapseWriter
if(!fileStream){
var currentDate = s.formattedTime(null,'YYYY-MM-DD')
@ -1132,6 +1133,7 @@ module.exports = (s,config,lang) => {
fs.mkdirSync(location)
}
fileStream = fs.createWriteStream(location + filename)
fileStream.on('error', err => s.debugLog(err))
fileStream.on('close', function () {
activeMonitor.recordTimelapseWriter = null
s.createTimelapseFrameAndInsert(e,location,filename)
@ -1144,6 +1146,9 @@ module.exports = (s,config,lang) => {
activeMonitor.recordTimelapseWriterTimeout = setTimeout(function(){
fileStream.end()
},900)
}catch(err){
s.debugLog(err)
}
})
}
if(e.details.detector === '1'){