ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix total video file size
Chocobozzzbce0f2f11b2e
diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.tsindex 1ee53ee1d6..7947c8760d 100644--- a/client/src/app/+admin/overview/videos/video-list.component.ts+++ b/client/src/app/+admin/overview/videos/video-list.component.ts@@ -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}diff --git a/packages/tests/src/api/videos/video-source.ts b/packages/tests/src/api/videos/video-source.tsindex 990802af2a..634144f136 100644--- a/packages/tests/src/api/videos/video-source.ts+++ b/packages/tests/src/api/videos/video-source.ts@@ -165,15 +165,17 @@ describe('Test video source management', function () {expect(data[1].videoSource.fileDownloadUrl).to.existexpect(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 () {diff --git a/server/core/controllers/api/videos/source.ts b/server/core/controllers/api/videos/source.tsindex 3787ffe740..591119ac04 100644--- a/server/core/controllers/api/videos/source.ts+++ b/server/core/controllers/api/videos/source.ts@@ -68,12 +68,8 @@ async function deleteVideoLatestSourceFile (req: express.Request, res: express.Rawait 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)diff --git a/server/core/models/video/sql/video/videos-id-list-query-builder.ts b/server/core/models/video/sql/video/videos-id-list-query-builder.tsindex 548ab5a222..1a8447b564 100644--- a/server/core/models/video/sql/video/videos-id-list-query-builder.ts+++ b/server/core/models/video/sql/video/videos-id-list-query-builder.ts@@ -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"')