+
+ logger.info('Duplicated %s - %d -> %s.', video.url, file.resolution, createdModel.url)
+ }
+ }
+
+ private async extendsExpirationOf (redundancy: VideoRedundancyModel, expiresAfterMs: number) {
+ logger.info('Extending expiration of %s.', redundancy.url)
+
+ const serverActor = await getServerActor()
+
+ redundancy.expiresOn = this.buildNewExpiration(expiresAfterMs)
+ await redundancy.save()
+
+ await sendUpdateCacheFile(serverActor, redundancy)
+ }
+
+ private async purgeCacheIfNeeded (redundancy: VideosRedundancy, filesToDuplicate: VideoFileModel[]) {
+ while (this.isTooHeavy(redundancy, filesToDuplicate)) {
+ const toDelete = await VideoRedundancyModel.loadOldestLocalThatAlreadyExpired(redundancy.strategy, redundancy.minLifetime)
+ if (!toDelete) return
+
+ await removeVideoRedundancy(toDelete)