From 53e7f82fe394eff220e1b76aa4d2b6018ed26267 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 26 May 2021 09:44:16 +0200 Subject: Fix redundancy max size --- .../lib/schedulers/videos-redundancy-scheduler.ts | 4 +- server/models/redundancy/video-redundancy.ts | 44 ---------------------- 2 files changed, 2 insertions(+), 46 deletions(-) (limited to 'server') diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts index 9e2667416..59b55cccc 100644 --- a/server/lib/schedulers/videos-redundancy-scheduler.ts +++ b/server/lib/schedulers/videos-redundancy-scheduler.ts @@ -317,8 +317,8 @@ export class VideosRedundancyScheduler extends AbstractScheduler { private async isTooHeavy (candidateToDuplicate: CandidateToDuplicate) { const maxSize = candidateToDuplicate.redundancy.size - const totalDuplicated = await VideoRedundancyModel.getTotalDuplicated(candidateToDuplicate.redundancy.strategy) - const totalWillDuplicate = totalDuplicated + this.getTotalFileSizes(candidateToDuplicate.files, candidateToDuplicate.streamingPlaylists) + const { totalUsed } = await VideoRedundancyModel.getStats(candidateToDuplicate.redundancy.strategy) + const totalWillDuplicate = totalUsed + this.getTotalFileSizes(candidateToDuplicate.files, candidateToDuplicate.streamingPlaylists) return totalWillDuplicate > maxSize } diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts index 53ebadeaf..a61c3578c 100644 --- a/server/models/redundancy/video-redundancy.ts +++ b/server/models/redundancy/video-redundancy.ts @@ -407,50 +407,6 @@ export class VideoRedundancyModel extends Model { return VideoRedundancyModel.scope([ ScopeNames.WITH_VIDEO ]).findOne(query) } - static async getTotalDuplicated (strategy: VideoRedundancyStrategy) { - const actor = await getServerActor() - const redundancyInclude = { - attributes: [], - model: VideoRedundancyModel, - required: true, - where: { - actorId: actor.id, - strategy - } - } - - const queryFiles: FindOptions = { - include: [ redundancyInclude ] - } - - const queryStreamingPlaylists: FindOptions = { - include: [ - { - attributes: [], - model: VideoModel.unscoped(), - required: true, - include: [ - { - required: true, - attributes: [], - model: VideoStreamingPlaylistModel.unscoped(), - include: [ - redundancyInclude - ] - } - ] - } - ] - } - - return Promise.all([ - VideoFileModel.aggregate('size', 'SUM', queryFiles), - VideoFileModel.aggregate('size', 'SUM', queryStreamingPlaylists) - ]).then(([ r1, r2 ]) => { - return parseAggregateResult(r1) + parseAggregateResult(r2) - }) - } - static async listLocalExpired () { const actor = await getServerActor() -- cgit v1.2.3 From f49b3231d080767128c80dca7630a1ba9950ed12 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 26 May 2021 12:03:44 +0200 Subject: Fix broken lives handling --- server/models/video/video.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'server') diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 8c316e00c..18afba1ba 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -1008,6 +1008,7 @@ export class VideoModel extends Model { attributes: [ 'id' ], where: { isLive: true, + remote: false, state: VideoState.PUBLISHED } } -- cgit v1.2.3