From 3ef5909aecf5aa33c9f1235df81d4f8c5c8948f6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 12 Nov 2021 09:02:53 +0100 Subject: [PATCH] Fix extendsLocalExpiration for redundancy --- .../lib/schedulers/videos-redundancy-scheduler.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts index 155d43343..16562ad0b 100644 --- a/server/lib/schedulers/videos-redundancy-scheduler.ts +++ b/server/lib/schedulers/videos-redundancy-scheduler.ts @@ -115,19 +115,11 @@ export class VideosRedundancyScheduler extends AbstractScheduler { for (const redundancyModel of expired) { try { const redundancyConfig = CONFIG.REDUNDANCY.VIDEOS.STRATEGIES.find(s => s.strategy === redundancyModel.strategy) - const candidate: CandidateToDuplicate = { - redundancy: redundancyConfig, - video: null, - files: [], - streamingPlaylists: [] - } + const { totalUsed } = await VideoRedundancyModel.getStats(redundancyConfig.strategy) // If the administrator disabled the redundancy or decreased the cache size, remove this redundancy instead of extending it - if (!redundancyConfig || await this.isTooHeavy(candidate)) { - logger.info( - 'Destroying redundancy %s because the cache size %s is too heavy.', - redundancyModel.url, redundancyModel.strategy, lTags(candidate.video.uuid) - ) + if (!redundancyConfig || totalUsed > redundancyConfig.size) { + logger.info('Destroying redundancy %s because the cache size %s is too heavy.', redundancyModel.url, redundancyModel.strategy) await removeVideoRedundancy(redundancyModel) } else {