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 +++++++++++-------- server/lib/live/live-manager.ts | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'server/lib') 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 { diff --git a/server/lib/live/live-manager.ts b/server/lib/live/live-manager.ts index 0f14a6851..f2f064b49 100644 --- a/server/lib/live/live-manager.ts +++ b/server/lib/live/live-manager.ts @@ -416,6 +416,7 @@ class LiveManager { : undefined, liveSessionId: liveSession.id, + streamingPlaylistId: fullVideo.getHLSPlaylist()?.id, publishedAt: fullVideo.publishedAt.toISOString() } -- cgit v1.2.3