Fix longstanding issue with incorrect file size calculation
parent
c44faa94ad
commit
f5f89e6d74
|
@ -283,7 +283,7 @@ module.exports = function(s,config){
|
|||
}
|
||||
s.kilobyteToMegabyte = function(kb,places){
|
||||
if(!places)places = 2
|
||||
return (kb/1000000).toFixed(places)
|
||||
return (kb/1048576).toFixed(places)
|
||||
}
|
||||
Object.defineProperty(Array.prototype, 'chunk', {
|
||||
value: function(chunkSize){
|
||||
|
|
|
@ -145,7 +145,7 @@ module.exports = function(s,config,lang,app,io){
|
|||
dir : s.getVideoDirectory(d.d),
|
||||
file : d.filename,
|
||||
filename : d.filename,
|
||||
filesizeMB : parseFloat((d.filesize/1000000).toFixed(2))
|
||||
filesizeMB : parseFloat((d.filesize/1048576).toFixed(2))
|
||||
}
|
||||
s.insertDatabaseRow(d.d,insert)
|
||||
s.insertCompletedVideoExtensions.forEach(function(extender){
|
||||
|
|
|
@ -144,10 +144,10 @@ module.exports = function(s,config,lang,io){
|
|||
}
|
||||
})
|
||||
}
|
||||
s.group[user.ke].usedSpace = (usedSpaceVideos + usedSpaceTimelapseFrames + usedSpaceFilebin) / 1000000
|
||||
s.group[user.ke].usedSpaceVideos = usedSpaceVideos / 1000000
|
||||
s.group[user.ke].usedSpaceFilebin = usedSpaceFilebin / 1000000
|
||||
s.group[user.ke].usedSpaceTimelapseFrames = usedSpaceTimelapseFrames / 1000000
|
||||
s.group[user.ke].usedSpace = (usedSpaceVideos + usedSpaceTimelapseFrames + usedSpaceFilebin) / 1048576
|
||||
s.group[user.ke].usedSpaceVideos = usedSpaceVideos / 1048576
|
||||
s.group[user.ke].usedSpaceFilebin = usedSpaceFilebin / 1048576
|
||||
s.group[user.ke].usedSpaceTimelapseFrames = usedSpaceTimelapseFrames / 1048576
|
||||
loadAddStorageDiskUseForUser(user,addStorageData,function(){
|
||||
callback()
|
||||
})
|
||||
|
@ -173,7 +173,7 @@ module.exports = function(s,config,lang,io){
|
|||
videos.forEach(function(video){
|
||||
var storageType = JSON.parse(video.details).type
|
||||
if(!storageType)storageType = 's3'
|
||||
var videoSize = video.size / 1000000
|
||||
var videoSize = video.size / 1048576
|
||||
user.cloudDiskUse[storageType].usedSpace += videoSize
|
||||
user.cloudDiskUse[storageType].usedSpaceVideos += videoSize
|
||||
++user.cloudDiskUse[storageType].firstCount
|
||||
|
@ -193,7 +193,7 @@ module.exports = function(s,config,lang,io){
|
|||
frames.forEach(function(frame){
|
||||
var storageType = JSON.parse(frame.details).type
|
||||
if(!storageType)storageType = 's3'
|
||||
var frameSize = frame.size / 1000000
|
||||
var frameSize = frame.size / 1048576
|
||||
user.cloudDiskUse[storageType].usedSpace += frameSize
|
||||
user.cloudDiskUse[storageType].usedSpaceTimelapseFrames += frameSize
|
||||
})
|
||||
|
@ -260,10 +260,10 @@ module.exports = function(s,config,lang,io){
|
|||
}
|
||||
})
|
||||
}
|
||||
storageIndex.usedSpace = (usedSpaceVideos + usedSpaceTimelapseFrames + usedSpaceFilebin) / 1000000
|
||||
storageIndex.usedSpaceVideos = usedSpaceVideos / 1000000
|
||||
storageIndex.usedSpaceFilebin = usedSpaceFilebin / 1000000
|
||||
storageIndex.usedSpaceTimelapseFrames = usedSpaceTimelapseFrames / 1000000
|
||||
storageIndex.usedSpace = (usedSpaceVideos + usedSpaceTimelapseFrames + usedSpaceFilebin) / 1048576
|
||||
storageIndex.usedSpaceVideos = usedSpaceVideos / 1048576
|
||||
storageIndex.usedSpaceFilebin = usedSpaceFilebin / 1048576
|
||||
storageIndex.usedSpaceTimelapseFrames = usedSpaceTimelapseFrames / 1048576
|
||||
s.systemLog(user.mail+' : '+path+' : '+videos.length,storageIndex.usedSpace)
|
||||
++currentStorageNumber
|
||||
readStorageArray()
|
||||
|
|
|
@ -75,7 +75,7 @@ module.exports = function(s,config,lang,app,io){
|
|||
}
|
||||
s.insertTimelapseFrameDatabaseRow = function(e,queryInfo,filePath){
|
||||
s.sqlQuery('INSERT INTO `Timelapse Frames` ('+Object.keys(queryInfo).join(',')+') VALUES (?,?,?,?,?,?)',Object.values(queryInfo))
|
||||
s.setDiskUsedForGroup(e,queryInfo.size / 1000000,'timelapeFrames')
|
||||
s.setDiskUsedForGroup(e,queryInfo.size / 1048576,'timelapeFrames')
|
||||
s.purgeDiskForGroup(e)
|
||||
s.onInsertTimelapseFrameExtensions.forEach(function(extender){
|
||||
extender(e,queryInfo,filePath)
|
||||
|
|
18
libs/user.js
18
libs/user.js
|
@ -53,11 +53,11 @@ module.exports = function(s,config,lang){
|
|||
})
|
||||
if(storageIndex){
|
||||
s.setDiskUsedForGroupAddStorage(e,{
|
||||
size: -(video.size/1000000),
|
||||
size: -(video.size/1048576),
|
||||
storageIndex: storageIndex
|
||||
})
|
||||
}else{
|
||||
s.setDiskUsedForGroup(e,-(video.size/1000000))
|
||||
s.setDiskUsedForGroup(e,-(video.size/1048576))
|
||||
}
|
||||
s.tx({
|
||||
f: 'video_delete',
|
||||
|
@ -106,11 +106,11 @@ module.exports = function(s,config,lang){
|
|||
})
|
||||
if(storageIndex){
|
||||
s.setDiskUsedForGroupAddStorage(e,{
|
||||
size: -(frame.size/1000000),
|
||||
size: -(frame.size/1048576),
|
||||
storageIndex: storageIndex
|
||||
},'timelapeFrames')
|
||||
}else{
|
||||
s.setDiskUsedForGroup(e,-(frame.size/1000000),'timelapeFrames')
|
||||
s.setDiskUsedForGroup(e,-(frame.size/1048576),'timelapeFrames')
|
||||
}
|
||||
// s.tx({
|
||||
// f: 'timelapse_frame_delete',
|
||||
|
@ -158,11 +158,11 @@ module.exports = function(s,config,lang){
|
|||
})
|
||||
if(storageIndex){
|
||||
s.setDiskUsedForGroupAddStorage(e,{
|
||||
size: -(file.size/1000000),
|
||||
size: -(file.size/1048576),
|
||||
storageIndex: storageIndex
|
||||
},'fileBin')
|
||||
}else{
|
||||
s.setDiskUsedForGroup(e,-(file.size/1000000),'fileBin')
|
||||
s.setDiskUsedForGroup(e,-(file.size/1048576),'fileBin')
|
||||
}
|
||||
})
|
||||
}else{
|
||||
|
@ -334,7 +334,7 @@ module.exports = function(s,config,lang){
|
|||
s.group[e.ke].sizeLimitTimelapseFramesPercent = parseFloat(s.group[e.ke].init.size_timelapse_percent) || 5
|
||||
s.group[e.ke].sizeLimitFileBinPercent = parseFloat(s.group[e.ke].init.size_filebin_percent) || 5
|
||||
//save global used space as megabyte value
|
||||
s.group[e.ke].usedSpace = s.group[e.ke].usedSpace || ((e.size || 0) / 1000000)
|
||||
s.group[e.ke].usedSpace = s.group[e.ke].usedSpace || ((e.size || 0) / 1048576)
|
||||
//emit the changes to connected users
|
||||
s.sendDiskUsedAmountToClients(e)
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ module.exports = function(s,config,lang){
|
|||
queryValues.push(video.mid)
|
||||
queryValues.push(video.time)
|
||||
s.setCloudDiskUsedForGroup(e,{
|
||||
amount : -(video.size/1000000),
|
||||
amount : -(video.size/1048576),
|
||||
storageType : storageType
|
||||
})
|
||||
s.deleteVideoFromCloudExtensionsRunner(e,storageType,video)
|
||||
|
@ -435,7 +435,7 @@ module.exports = function(s,config,lang){
|
|||
queryValues.push(frame.mid)
|
||||
queryValues.push(frame.time)
|
||||
s.setCloudDiskUsedForGroup(e,{
|
||||
amount : -(frame.size/1000000),
|
||||
amount : -(frame.size/1048576),
|
||||
storageType : storageType
|
||||
})
|
||||
s.deleteVideoFromCloudExtensionsRunner(e,storageType,frame)
|
||||
|
|
|
@ -32,7 +32,7 @@ module.exports = function(s,config,lang,app,io){
|
|||
}
|
||||
var timeNow = new Date(s.nameToTime(filename))
|
||||
s.sqlQuery('INSERT INTO `Timelapse Frames` (ke,mid,details,filename,size,time) VALUES (?,?,?,?,?,?)',[ke,mid,s.s(details),filename,fileStats.size,timeNow])
|
||||
s.setDiskUsedForGroup(monitor,fileStats.size / 1000000)
|
||||
s.setDiskUsedForGroup(monitor,fileStats.size / 1048576)
|
||||
}
|
||||
// else{
|
||||
// s.insertDatabaseRow(
|
||||
|
|
|
@ -111,7 +111,7 @@ module.exports = function(s,config,lang){
|
|||
k.details = {}
|
||||
k.stat = fs.statSync(k.dir+k.file)
|
||||
k.filesize = k.stat.size
|
||||
k.filesizeMB = parseFloat((k.filesize/1000000).toFixed(2))
|
||||
k.filesizeMB = parseFloat((k.filesize/1048576).toFixed(2))
|
||||
|
||||
k.startTime = new Date(s.nameToTime(k.file))
|
||||
k.endTime = new Date(k.endTime || k.stat.mtime)
|
||||
|
@ -226,11 +226,11 @@ module.exports = function(s,config,lang){
|
|||
var storageIndex = s.getVideoStorageIndex(e)
|
||||
if(storageIndex){
|
||||
s.setDiskUsedForGroupAddStorage(e,{
|
||||
size: -(r.size / 1000000),
|
||||
size: -(r.size / 1048576),
|
||||
storageIndex: storageIndex
|
||||
})
|
||||
}else{
|
||||
s.setDiskUsedForGroup(e,-(r.size / 1000000))
|
||||
s.setDiskUsedForGroup(e,-(r.size / 1048576))
|
||||
}
|
||||
s.sqlQuery('DELETE FROM Videos WHERE `mid`=? AND `ke`=? AND `time`=?',queryValues,function(err){
|
||||
if(err){
|
||||
|
@ -288,11 +288,11 @@ module.exports = function(s,config,lang){
|
|||
var storageIndex = s.getVideoStorageIndex(video)
|
||||
if(storageIndex){
|
||||
s.setDiskUsedForGroupAddStorage(video,{
|
||||
size: -(video.size / 1000000),
|
||||
size: -(video.size / 1048576),
|
||||
storageIndex: storageIndex
|
||||
})
|
||||
}else{
|
||||
s.setDiskUsedForGroup(video,-(video.size / 1000000))
|
||||
s.setDiskUsedForGroup(video,-(video.size / 1048576))
|
||||
}
|
||||
fs.unlink(video.dir+filename,function(err){
|
||||
fs.stat(video.dir+filename,function(err){
|
||||
|
@ -487,7 +487,7 @@ module.exports = function(s,config,lang){
|
|||
var fileStats = fs.statSync(finalMp4OutputLocation)
|
||||
var details = {}
|
||||
s.sqlQuery('INSERT INTO `Files` (ke,mid,details,name,size,time) VALUES (?,?,?,?,?,?)',[ke,mid,s.s(details),finalFileName + '.mp4',fileStats.size,timeNow])
|
||||
s.setDiskUsedForGroup({ke: ke},fileStats.size / 1000000,'fileBin')
|
||||
s.setDiskUsedForGroup({ke: ke},fileStats.size / 1048576,'fileBin')
|
||||
fs.unlink(commandTempLocation,function(){
|
||||
|
||||
})
|
||||
|
|
|
@ -19,7 +19,7 @@ $.ccio.tm=function(x,d,z,user){
|
|||
d.hr=parseInt(d.startMoment.format('HH')),
|
||||
d.per=parseInt(d.hr/24*100);
|
||||
d.circle='<div title="at '+d.hr+' hours of '+d.startMoment.format('MMMM DD')+'" '+href+' video="launch" class="progress-circle progress-'+d.per+'"><span>'+d.hr+'</span></div>'
|
||||
tmp+='<li class="video-item glM'+d.mid+user.auth_token+'" auth="'+user.auth_token+'" mid="'+d.mid+'" ke="'+d.ke+'" status="'+d.status+'" status="'+d.status+'" file="'+d.filename+'">'+d.circle+'<div><span title="'+d.endMoment.format()+'" class="livestamp"></span></div><div><div class="small"><b>'+lang.Start+'</b> : '+d.startMoment.format('h:mm:ss , MMMM Do YYYY')+'</div><div class="small"><b>'+lang.End+'</b> : '+d.endMoment.format('h:mm:ss , MMMM Do YYYY')+'</div></div><div><span class="pull-right">'+(parseInt(d.size)/1000000).toFixed(2)+'mb</span><div class="controls btn-group"><a class="btn btn-sm btn-primary" video="launch" '+href+'><i class="fa fa-play-circle"></i></a> <a download="'+d.dlname+'" '+href+' class="btn btn-sm btn-default"><i class="fa fa-download"></i></a>'
|
||||
tmp+='<li class="video-item glM'+d.mid+user.auth_token+'" auth="'+user.auth_token+'" mid="'+d.mid+'" ke="'+d.ke+'" status="'+d.status+'" status="'+d.status+'" file="'+d.filename+'">'+d.circle+'<div><span title="'+d.endMoment.format()+'" class="livestamp"></span></div><div><div class="small"><b>'+lang.Start+'</b> : '+d.startMoment.format('h:mm:ss , MMMM Do YYYY')+'</div><div class="small"><b>'+lang.End+'</b> : '+d.endMoment.format('h:mm:ss , MMMM Do YYYY')+'</div></div><div><span class="pull-right">'+(parseInt(d.size)/1048576).toFixed(2)+'mb</span><div class="controls btn-group"><a class="btn btn-sm btn-primary" video="launch" '+href+'><i class="fa fa-play-circle"></i></a> <a download="'+d.dlname+'" '+href+' class="btn btn-sm btn-default"><i class="fa fa-download"></i></a>'
|
||||
if($.ccio.DropboxAppKey){
|
||||
tmp+='<a video="download" host="dropbox" download="'+d.dlname+'" '+href+' class="btn btn-sm btn-default"><i class="fa fa-dropbox"></i></a>'
|
||||
}
|
||||
|
|
|
@ -505,7 +505,7 @@ $(document).ready(function(e){
|
|||
if(v.status !== 0){
|
||||
$.vidview.loadedVideos[v.filename] = Object.assign(v,{})
|
||||
var n=$.ccio.mon[v.ke+v.mid+user.auth_token];
|
||||
if(n){v.title=n.name+' - '+(parseInt(v.size)/1000000).toFixed(2)+'mb';}
|
||||
if(n){v.title=n.name+' - '+(parseInt(v.size)/1048576).toFixed(2)+'mb';}
|
||||
v.start=v.time;
|
||||
// v.filename=$.ccio.init('tf',v.time)+'.'+v.ext;
|
||||
e.ar.push(v);
|
||||
|
@ -618,7 +618,7 @@ $(document).ready(function(e){
|
|||
tmp+='<td title="'+v.time+'">'+$.ccio.timeObject(v.time).format('h:mm:ss A, MMMM Do YYYY')+'</td>';
|
||||
tmp+='<td>'+v.mon.name+'</td>';
|
||||
tmp+='<td>'+v.filename+'</td>';
|
||||
tmp+='<td>'+(parseInt(v.size)/1000000).toFixed(2)+'</td>';
|
||||
tmp+='<td>'+(parseInt(v.size)/1048576).toFixed(2)+'</td>';
|
||||
tmp+='<td><a class="btn btn-sm btn-default preview" href="'+href+'"> <i class="fa fa-play-circle"></i> </a></td>';
|
||||
tmp+='<td><a class="btn btn-sm btn-primary" video="launch" href="'+href+'"> <i class="fa fa-play-circle"></i> </a></td>';
|
||||
tmp+='<td><a class="btn btn-sm btn-success" download="'+v.mid+'-'+v.filename+'" href="'+href+'"> <i class="fa fa-download"></i> </a></td>';
|
||||
|
|
|
@ -944,7 +944,7 @@ switch($user.details.lang){
|
|||
d.hr=parseInt(d.startMoment.format('HH')),
|
||||
d.per=parseInt(d.hr/24*100);
|
||||
d.circle='<div title="at '+d.hr+' hours of '+d.startMoment.format('MMMM DD')+'" '+href+' video="launch" class="progress-circle progress-'+d.per+'"><span>'+d.hr+'</span></div>'
|
||||
tmp+='<li class="video-item glM'+d.mid+user.auth_token+'" auth="'+user.auth_token+'" mid="'+d.mid+'" ke="'+d.ke+'" status="'+d.status+'" status="'+d.status+'" file="'+d.filename+'">'+d.circle+'<div><span title="'+d.endMoment.format()+'" class="livestamp"></span></div><div><div class="small"><b>'+lang.Start+'</b> : '+d.startMoment.format('h:mm:ss , MMMM Do YYYY')+'</div><div class="small"><b>'+lang.End+'</b> : '+d.endMoment.format('h:mm:ss , MMMM Do YYYY')+'</div></div><div><span class="pull-right">'+(parseInt(d.size)/1000000).toFixed(2)+'mb</span><div class="controls btn-group"><a class="btn btn-sm btn-primary" video="launch" '+href+'><i class="fa fa-play-circle"></i></a> <a download="'+d.dlname+'" '+href+' class="btn btn-sm btn-default"><i class="fa fa-download"></i></a>'
|
||||
tmp+='<li class="video-item glM'+d.mid+user.auth_token+'" auth="'+user.auth_token+'" mid="'+d.mid+'" ke="'+d.ke+'" status="'+d.status+'" status="'+d.status+'" file="'+d.filename+'">'+d.circle+'<div><span title="'+d.endMoment.format()+'" class="livestamp"></span></div><div><div class="small"><b>'+lang.Start+'</b> : '+d.startMoment.format('h:mm:ss , MMMM Do YYYY')+'</div><div class="small"><b>'+lang.End+'</b> : '+d.endMoment.format('h:mm:ss , MMMM Do YYYY')+'</div></div><div><span class="pull-right">'+(parseInt(d.size)/1048576).toFixed(2)+'mb</span><div class="controls btn-group"><a class="btn btn-sm btn-primary" video="launch" '+href+'><i class="fa fa-play-circle"></i></a> <a download="'+d.dlname+'" '+href+' class="btn btn-sm btn-default"><i class="fa fa-download"></i></a>'
|
||||
<% if(config.DropboxAppKey){ %> tmp+='<a video="download" host="dropbox" download="'+d.dlname+'" '+href+' class="btn btn-sm btn-default"><i class="fa fa-dropbox"></i></a>' <% } %>
|
||||
tmp+='<a title="'+lang['Delete Video']+'" video="delete" href="'+$.ccio.init('videoHrefToDelete',url)+'" class="btn btn-sm btn-danger permission_video_delete"><i class="fa fa-trash"></i></a></div></div></li>';
|
||||
$(z).each(function(n,v){
|
||||
|
@ -5775,7 +5775,7 @@ $('body')
|
|||
if(v.status !== 0){
|
||||
$.vidview.loadedVideos[v.filename] = Object.assign(v,{})
|
||||
var n=$.ccio.mon[v.ke+v.mid+user.auth_token];
|
||||
if(n){v.title=n.name+' - '+(parseInt(v.size)/1000000).toFixed(2)+'mb';}
|
||||
if(n){v.title=n.name+' - '+(parseInt(v.size)/1048576).toFixed(2)+'mb';}
|
||||
v.start=v.time;
|
||||
// v.filename=$.ccio.init('tf',v.time)+'.'+v.ext;
|
||||
e.ar.push(v);
|
||||
|
@ -5878,7 +5878,7 @@ $('body')
|
|||
tmp+='<td title="'+v.time+'">'+$.ccio.timeObject(v.time).format('h:mm:ss A, MMMM Do YYYY')+'</td>';
|
||||
tmp+='<td>'+v.mon.name+'</td>';
|
||||
tmp+='<td>'+v.filename+'</td>';
|
||||
tmp+='<td>'+(parseInt(v.size)/1000000).toFixed(2)+'</td>';
|
||||
tmp+='<td>'+(parseInt(v.size)/1048576).toFixed(2)+'</td>';
|
||||
tmp+='<td><a class="btn btn-sm btn-default preview" href="'+href+'"> <i class="fa fa-play-circle"></i> </a></td>';
|
||||
tmp+='<td><a class="btn btn-sm btn-primary" video="launch" href="'+href+'"> <i class="fa fa-play-circle"></i> </a></td>';
|
||||
tmp+='<td><a class="btn btn-sm btn-success" download="'+v.mid+'-'+v.filename+'" href="'+href+'"> <i class="fa fa-download"></i> </a></td>';
|
||||
|
|
Loading…
Reference in New Issue