X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fschedulers%2Fvideos-redundancy-scheduler.ts;h=91c217615f12d989e2c7722baf1d819eb3005b70;hb=68d6e57870dd5ea87a03d13adcfcc72786d8348a;hp=155d43343858bc131df063c680e4a3e827dffe1a;hpb=02b286f89088e07cac7e7068e884d3be0fd0098b;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts index 155d43343..91c217615 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 { @@ -360,7 +352,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler { // We need more attributes and check if the video still exists const getVideoOptions = { videoObject: videoUrl, - syncParam: { likes: false, dislikes: false, shares: false, comments: false, thumbnail: false, refreshVideo: true }, + syncParam: { rates: false, shares: false, comments: false, thumbnail: false, refreshVideo: true }, fetchType: 'all' as 'all' } const { video } = await getOrCreateAPVideo(getVideoOptions)