mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-08-17 09:20:26 +03:00
Fix total video file size
This commit is contained in:
parent
da949376db
commit
bce0f2f11b
@ -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
|
||||
}
|
||||
|
@ -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 () {
|
||||
|
@ -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)
|
||||
|
@ -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"'
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user