Skip to content

Commit

Permalink
many bug fixes
Browse files Browse the repository at this point in the history
- cn.embedded call on logout
- opening video 2 seconds late
- delete motionless size init
- mp4ception in video filename during delete
  • Loading branch information
moeiscool committed Mar 14, 2018
1 parent 8570a3b commit cb25332
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,21 +779,27 @@ s.video=function(x,e){
break;
case'delete':
if(!e.filename&&e.time){e.filename=s.moment(e.time)}
var filename
if(e.filename.indexOf('.')>-1){
filename = e.filename
}else{
filename = e.filename+'.'+e.ext
}
if(!e.status){e.status=0}
e.save=[e.id,e.ke,s.nameToTime(e.filename)];
e.save=[e.id,e.ke,s.nameToTime(filename)];
s.sqlQuery('SELECT * FROM Videos WHERE `mid`=? AND `ke`=? AND `time`=?',e.save,function(err,r){
if(r&&r[0]){
r=r[0]
e.dir=s.video('getDir',r)
var dir=s.video('getDir',r)
s.sqlQuery('DELETE FROM Videos WHERE `mid`=? AND `ke`=? AND `time`=?',e.save,function(){
fs.stat(e.dir+e.filename+'.'+e.ext,function(err,file){
fs.stat(dir+filename,function(err,file){
if(err){
s.systemLog('File Delete Error : '+e.ke+' : '+' : '+e.mid,err)
}
s.init('diskUsedSet',e,-(r.size/1000000))
})
s.tx({f:'video_delete',filename:e.filename+'.'+e.ext,mid:e.mid,ke:e.ke,time:s.nameToTime(e.filename),end:s.moment(new Date,'YYYY-MM-DD HH:mm:ss')},'GRP_'+e.ke);
s.file('delete',e.dir+e.filename+'.'+e.ext)
s.tx({f:'video_delete',filename:filename,mid:e.mid,ke:e.ke,time:s.nameToTime(filename),end:s.moment(new Date,'YYYY-MM-DD HH:mm:ss')},'GRP_'+e.ke);
s.file('delete',dir+filename)
})
}
})
Expand Down Expand Up @@ -1926,20 +1932,21 @@ s.camera=function(x,e,cn,tx){
if(exists){
if(s.group[e.ke].mon[e.id].open){
s.video('close',e);
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:e.filename+'.'+e.ext});
var row = Object.assign({},s.init('noReference',e));
setTimeout(function(){

This comment has been minimized.

Copy link
@vmirage

vmirage Apr 12, 2018

Contributor

Why is setTimeout moved here?

if(row.details.detector==='1'&&s.group[row.ke].mon[row.id].started===1&&row.details&&row.details.detector_record_method==='del'&&row.details.detector_delete_motionless_videos==='1'&&s.group[row.ke].mon[row.id].detector_motion_count===0){

This comment has been minimized.

Copy link
@vmirage

vmirage Apr 12, 2018

Contributor

This will always be false since it is executed 2 seconds after detector_motion_count is set to 0 below

This comment has been minimized.

Copy link
@moeiscool

moeiscool Apr 12, 2018

Author Collaborator

weird s.group[d.ke].mon[d.id].detector_motion_count+=1 seems to add to it? or does it not work on yours?

This comment has been minimized.

Copy link
@vmirage

vmirage Apr 12, 2018

Contributor

Yes it is added. But if you notice, this code is running in setTimeout after 2 seconds. So the code below would have executed first and reset it to 0 before this code could execute

if(row.details.loglevel!=='quiet'){
s.log(row,{type:lang['Delete Motionless Video'],msg:row.filename+'.'+row.ext});
}
s.video('delete',row)
}
s.video('delete',s.init('noReference',e))
}
},2000)
}
setTimeout(function(){
e.filename=filename.split('.')[0];
s.video('open',e);
s.group[e.ke].mon[e.id].open=e.filename;
s.group[e.ke].mon[e.id].open_ext=e.ext;
s.group[e.ke].mon[e.id].detector_motion_count=0;
},1500)
e.filename=filename.split('.')[0];
s.video('open',e);
s.group[e.ke].mon[e.id].open=e.filename;
s.group[e.ke].mon[e.id].open_ext=e.ext;
s.group[e.ke].mon[e.id].detector_motion_count=0;

This comment has been minimized.

Copy link
@vmirage

vmirage Apr 12, 2018

Contributor

This seems to overwrite detector_motion_count to 0 before the setTimeout above can execute

This comment has been minimized.

Copy link
@moeiscool

moeiscool Apr 12, 2018

Author Collaborator

did you search detector_motion_count to find where it was used?

This comment has been minimized.

Copy link
@vmirage

vmirage Apr 12, 2018

Contributor

Yes... it is incremented in another part of the code but that is not the bug. The bug is this line of code where it is set to 0 before the setTimeout is executed

}
});
break;
Expand Down Expand Up @@ -3804,8 +3811,7 @@ var tx;
s.camera('watch_off',{id:v,ke:cn.monitor_watching[v].ke},s.cn(cn))
})
}
}
if(!cn.embedded){
}else if(!cn.embedded){
if(s.group[cn.ke].users[cn.auth].login_type==='Dashboard'){
s.tx({f:'user_status_change',ke:cn.ke,uid:cn.uid,status:0})
}
Expand Down

2 comments on commit cb25332

@vmirage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like delete_motionless_video condition won't do anything because the detector_motion_count is always set to 0 before the code could execute.

@moeiscool
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

search for detector_motion_count

Please sign in to comment.