Skip to content

Commit

Permalink
fix : deleting videos affects space count live
Browse files Browse the repository at this point in the history
  • Loading branch information
moeiscool committed May 29, 2017
1 parent ead7297 commit ad341c5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,13 @@ s.video=function(x,e){
if(!e.filename&&e.time){e.filename=s.moment(e.time)}
if(!e.status){e.status=0}
e.save=[e.id,e.ke,s.nameToTime(e.filename)];
sql.query('DELETE FROM Videos WHERE `mid`=? AND `ke`=? AND `time`=?',e.save,function(err,r){
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)
fs.stat(e.dir+e.filename+'.'+e.ext,function(err,file){
sql.query('DELETE FROM Videos WHERE `mid`=? AND `ke`=? AND `time`=?',e.save,function(err,r){
s.group[e.ke].init.used_space=s.group[e.ke].init.used_space-(file.size/1000000)
s.init('diskUsed',e)
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)
})
})
break;
case'open':
Expand Down

0 comments on commit ad341c5

Please sign in to comment.