diff options
author | Chocobozzz <me@florianbigard.com> | 2022-10-31 08:57:52 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-10-31 08:57:52 +0100 |
commit | 91c72729d893d89522da0d273fbb4c0bceaf79c3 (patch) | |
tree | 564ba52419d0972dba3756e6a765aeffe992857f /server/lib/schedulers/videos-redundancy-scheduler.ts | |
parent | eb8da03d1ca80dd143a85c006caa657488296594 (diff) | |
download | PeerTube-91c72729d893d89522da0d273fbb4c0bceaf79c3.tar.gz PeerTube-91c72729d893d89522da0d273fbb4c0bceaf79c3.tar.zst PeerTube-91c72729d893d89522da0d273fbb4c0bceaf79c3.zip |
Prevent error in redundancy scheduler
Diffstat (limited to 'server/lib/schedulers/videos-redundancy-scheduler.ts')
-rw-r--r-- | server/lib/schedulers/videos-redundancy-scheduler.ts | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts index 78245fa6a..dc450c338 100644 --- a/server/lib/schedulers/videos-redundancy-scheduler.ts +++ b/server/lib/schedulers/videos-redundancy-scheduler.ts | |||
@@ -115,16 +115,29 @@ export class VideosRedundancyScheduler extends AbstractScheduler { | |||
115 | for (const redundancyModel of expired) { | 115 | for (const redundancyModel of expired) { |
116 | try { | 116 | try { |
117 | const redundancyConfig = CONFIG.REDUNDANCY.VIDEOS.STRATEGIES.find(s => s.strategy === redundancyModel.strategy) | 117 | const redundancyConfig = CONFIG.REDUNDANCY.VIDEOS.STRATEGIES.find(s => s.strategy === redundancyModel.strategy) |
118 | |||
119 | // If the admin disabled the redundancy, remove this redundancy instead of extending it | ||
120 | if (!redundancyConfig) { | ||
121 | logger.info( | ||
122 | 'Destroying redundancy %s because the redundancy %s does not exist anymore.', | ||
123 | redundancyModel.url, redundancyModel.strategy | ||
124 | ) | ||
125 | |||
126 | await removeVideoRedundancy(redundancyModel) | ||
127 | continue | ||
128 | } | ||
129 | |||
118 | const { totalUsed } = await VideoRedundancyModel.getStats(redundancyConfig.strategy) | 130 | const { totalUsed } = await VideoRedundancyModel.getStats(redundancyConfig.strategy) |
119 | 131 | ||
120 | // If the administrator disabled the redundancy or decreased the cache size, remove this redundancy instead of extending it | 132 | // If the admin decreased the cache size, remove this redundancy instead of extending it |
121 | if (!redundancyConfig || totalUsed > redundancyConfig.size) { | 133 | if (totalUsed > redundancyConfig.size) { |
122 | logger.info('Destroying redundancy %s because the cache size %s is too heavy.', redundancyModel.url, redundancyModel.strategy) | 134 | logger.info('Destroying redundancy %s because the cache size %s is too heavy.', redundancyModel.url, redundancyModel.strategy) |
123 | 135 | ||
124 | await removeVideoRedundancy(redundancyModel) | 136 | await removeVideoRedundancy(redundancyModel) |
125 | } else { | 137 | continue |
126 | await this.extendsRedundancy(redundancyModel) | ||
127 | } | 138 | } |
139 | |||
140 | await this.extendsRedundancy(redundancyModel) | ||
128 | } catch (err) { | 141 | } catch (err) { |
129 | logger.error( | 142 | logger.error( |
130 | 'Cannot extend or remove expiration of %s video from our redundancy system.', | 143 | 'Cannot extend or remove expiration of %s video from our redundancy system.', |