From cdd838168d617f70fc04fe7f23846810e7e07082 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 16 Jun 2022 13:39:57 +0200 Subject: Fix live ending job that breaks new live session --- server/lib/job-queue/handlers/video-live-ending.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'server/lib/job-queue/handlers/video-live-ending.ts') diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts index 7607267f8..feec257fc 100644 --- a/server/lib/job-queue/handlers/video-live-ending.ts +++ b/server/lib/job-queue/handlers/video-live-ending.ts @@ -45,13 +45,13 @@ async function processVideoLiveEnding (job: Job) { LiveSegmentShaStore.Instance.cleanupShaSegments(liveVideo.uuid) if (live.saveReplay !== true) { - return cleanupLiveAndFederate({ live, video: liveVideo }) + return cleanupLiveAndFederate({ live, video: liveVideo, streamingPlaylistId: payload.streamingPlaylistId }) } if (live.permanentLive) { await saveReplayToExternalVideo({ liveVideo, liveSession, publishedAt: payload.publishedAt, replayDirectory: payload.replayDirectory }) - return cleanupLiveAndFederate({ live, video: liveVideo }) + return cleanupLiveAndFederate({ live, video: liveVideo, streamingPlaylistId: payload.streamingPlaylistId }) } return replaceLiveByReplay({ liveVideo, live, liveSession, replayDirectory: payload.replayDirectory }) @@ -233,15 +233,18 @@ async function assignReplayFilesToVideo (options: { async function cleanupLiveAndFederate (options: { live: MVideoLive video: MVideo + streamingPlaylistId: number }) { - const { live, video } = options + const { live, video, streamingPlaylistId } = options - const streamingPlaylist = await VideoStreamingPlaylistModel.loadHLSPlaylistByVideo(video.id) + const streamingPlaylist = await VideoStreamingPlaylistModel.loadWithVideo(streamingPlaylistId) - if (live.permanentLive) { - await cleanupPermanentLive(video, streamingPlaylist) - } else { - await cleanupNormalLive(video, streamingPlaylist) + if (streamingPlaylist) { + if (live.permanentLive) { + await cleanupPermanentLive(video, streamingPlaylist) + } else { + await cleanupNormalLive(video, streamingPlaylist) + } } try { -- cgit v1.2.3