]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix live tests
authorChocobozzz <me@florianbigard.com>
Wed, 13 Jul 2022 13:37:36 +0000 (15:37 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 13 Jul 2022 13:37:36 +0000 (15:37 +0200)
server/lib/live/shared/muxing-session.ts

index 036d9d142c5c1909fc96dc6880e2eeb37e6c1c69..55d070c963dc02c6eb4befc24d072a35b9b3018a 100644 (file)
@@ -249,8 +249,6 @@ class MuxingSession extends EventEmitter {
     const playlistIdMatcher = /^([\d+])-/
 
     const addHandler = async (segmentPath: string) => {
-      if (this.aborted) return
-
       logger.debug('Live add handler of %s.', segmentPath, this.lTags())
 
       const playlistId = basename(segmentPath).match(playlistIdMatcher)[0]
@@ -285,6 +283,7 @@ class MuxingSession extends EventEmitter {
 
   private async isQuotaExceeded (segmentPath: string) {
     if (this.saveReplay !== true) return false
+    if (this.aborted) return false
 
     try {
       const segmentStat = await stat(segmentPath)
@@ -337,8 +336,6 @@ class MuxingSession extends EventEmitter {
   }
 
   private processSegments (segmentPaths: string[]) {
-    if (this.aborted) return
-
     mapSeries(segmentPaths, async previousSegment => {
       // Add sha hash of previous segments, because ffmpeg should have finished generating them
       await LiveSegmentShaStore.Instance.addSegmentSha(this.videoUUID, previousSegment)
@@ -346,7 +343,11 @@ class MuxingSession extends EventEmitter {
       if (this.saveReplay) {
         await this.addSegmentToReplay(previousSegment)
       }
-    }).catch(err => logger.error('Cannot process segments', { err, ...this.lTags() }))
+    }).catch(err => {
+      if (this.aborted) return
+
+      logger.error('Cannot process segments', { err, ...this.lTags() })
+    })
   }
 
   private hasClientSocketInBadHealth (sessionId: string) {