Fix total video file size

This commit is contained in:
Chocobozzz 2024-04-22 11:48:05 +02:00
parent da949376db
commit bce0f2f11b
No known key found for this signature in database
GPG key ID: 583A612D890159BE
4 changed files with 23 additions and 18 deletions

View file

@ -216,7 +216,10 @@ export class VideoListComponent extends RestTable <Video> implements OnInit {
getFilesSize (video: Video) {
let total = getAllFiles(video).reduce((p, f) => p += f.size, 0)
total += video.videoSource?.size || 0
if (video.videoSource?.fileDownloadUrl) {
total += video.videoSource.size || 0
}
return total
}

View file

@ -165,15 +165,17 @@ describe('Test video source management', function () {
expect(data[1].videoSource.fileDownloadUrl).to.exist
expect(data[2].videoSource).to.exist
expect(data[2].videoSource.fileDownloadUrl).to.not.exist
expect(data[2].videoSource.createdAt).to.exist
expect(data[2].videoSource.fps).to.be.null
expect(data[2].videoSource.height).to.be.null
expect(data[2].videoSource.width).to.be.null
expect(data[2].videoSource.resolution.id).to.be.null
expect(data[2].videoSource.resolution.label).to.be.null
expect(data[2].videoSource.size).to.be.null
expect(data[2].videoSource.metadata).to.be.null
expect(data[2].videoSource.fps).to.to.exist
expect(data[2].videoSource.height).to.to.exist
expect(data[2].videoSource.width).to.to.exist
expect(data[2].videoSource.resolution.id).to.to.exist
expect(data[2].videoSource.resolution.label).to.to.exist
expect(data[2].videoSource.size).to.to.exist
expect(data[2].videoSource.metadata).to.to.exist
})
it('Should delete all videos and do not have original files anymore', async function () {

View file

@ -68,12 +68,8 @@ async function deleteVideoLatestSourceFile (req: express.Request, res: express.R
await video.removeOriginalFile(videoSource)
videoSource.keptOriginalFilename = null
videoSource.fps = null
videoSource.resolution = null
videoSource.width = null
videoSource.height = null
videoSource.metadata = null
videoSource.size = null
videoSource.storage = null
await videoSource.save()
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)

View file

@ -701,12 +701,16 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
'ELSE (' +
'(SELECT COALESCE(SUM(size), 0) FROM "videoFile" WHERE "videoFile"."videoId" = "video"."id")' +
' + ' +
'(SELECT COALESCE(SUM(size), 0) FROM "videoFile" ' +
'INNER JOIN "videoStreamingPlaylist" ON "videoStreamingPlaylist"."id" = "videoFile"."videoStreamingPlaylistId" ' +
'AND "videoStreamingPlaylist"."videoId" = "video"."id"' +
'(' +
'SELECT COALESCE(SUM(size), 0) FROM "videoFile" ' +
'INNER JOIN "videoStreamingPlaylist" ON "videoStreamingPlaylist"."id" = "videoFile"."videoStreamingPlaylistId" ' +
'AND "videoStreamingPlaylist"."videoId" = "video"."id"' +
')' +
' + ' +
'(SELECT COALESCE(SUM(size), 0) FROM "videoSource" WHERE "videoSource"."videoId" = "video"."id")' +
'(' +
'SELECT COALESCE(SUM(size), 0) FROM "videoSource" ' +
'WHERE "videoSource"."videoId" = "video"."id" AND "videoSource"."storage" IS NOT NULL' +
')' +
') END' +
') AS "localVideoFilesSize"'
)