]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/schedulers/videos-redundancy-scheduler.ts
Add redundancy check interval in config
[github/Chocobozzz/PeerTube.git] / server / lib / schedulers / videos-redundancy-scheduler.ts
index 5f9fd991129103bc96267670f4b8c566ee7a0fc1..96065171298d755fae9a2586673786cdb9ed7909 100644 (file)
@@ -18,7 +18,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
   private static instance: AbstractScheduler
   private executing = false
 
-  protected schedulerIntervalMs = SCHEDULER_INTERVALS_MS.videosRedundancy
+  protected schedulerIntervalMs = CONFIG.REDUNDANCY.VIDEOS.CHECK_INTERVAL
 
   private constructor () {
     super()
@@ -50,6 +50,16 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
       }
     }
 
+    await this.removeExpired()
+
+    this.executing = false
+  }
+
+  static get Instance () {
+    return this.instance || (this.instance = new this())
+  }
+
+  private async removeExpired () {
     const expired = await VideoRedundancyModel.listAllExpired()
 
     for (const m of expired) {
@@ -61,12 +71,6 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
         logger.error('Cannot remove %s video from our redundancy system.', this.buildEntryLogId(m))
       }
     }
-
-    this.executing = false
-  }
-
-  static get Instance () {
-    return this.instance || (this.instance = new this())
   }
 
   private findVideoToDuplicate (cache: VideosRedundancy) {