diff options
Diffstat (limited to 'server/lib/job-queue/handlers/video-live-ending.ts')
-rw-r--r-- | server/lib/job-queue/handlers/video-live-ending.ts | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts index 8a3ee09a2..abfaf1cd7 100644 --- a/server/lib/job-queue/handlers/video-live-ending.ts +++ b/server/lib/job-queue/handlers/video-live-ending.ts | |||
@@ -4,7 +4,7 @@ import { join } from 'path' | |||
4 | import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo } from '@server/helpers/ffmpeg' | 4 | import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo } from '@server/helpers/ffmpeg' |
5 | import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' | 5 | import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' |
6 | import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' | 6 | import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' |
7 | import { cleanupPermanentLive, cleanupTMPLiveFiles, cleanupUnsavedNormalLive } from '@server/lib/live' | 7 | import { cleanupAndDestroyPermanentLive, cleanupTMPLiveFiles, cleanupUnsavedNormalLive } from '@server/lib/live' |
8 | import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getLiveReplayBaseDirectory } from '@server/lib/paths' | 8 | import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getLiveReplayBaseDirectory } from '@server/lib/paths' |
9 | import { generateVideoMiniature } from '@server/lib/thumbnail' | 9 | import { generateVideoMiniature } from '@server/lib/thumbnail' |
10 | import { generateHlsPlaylistResolutionFromTS } from '@server/lib/transcoding/transcoding' | 10 | import { generateHlsPlaylistResolutionFromTS } from '@server/lib/transcoding/transcoding' |
@@ -141,23 +141,22 @@ async function replaceLiveByReplay (options: { | |||
141 | }) { | 141 | }) { |
142 | const { video, liveSession, live, permanentLive, replayDirectory } = options | 142 | const { video, liveSession, live, permanentLive, replayDirectory } = options |
143 | 143 | ||
144 | await cleanupTMPLiveFiles(video) | 144 | const videoWithFiles = await VideoModel.loadFull(video.id) |
145 | const hlsPlaylist = videoWithFiles.getHLSPlaylist() | ||
146 | |||
147 | await cleanupTMPLiveFiles(videoWithFiles, hlsPlaylist) | ||
145 | 148 | ||
146 | await live.destroy() | 149 | await live.destroy() |
147 | 150 | ||
148 | video.isLive = false | 151 | videoWithFiles.isLive = false |
149 | video.waitTranscoding = true | 152 | videoWithFiles.waitTranscoding = true |
150 | video.state = VideoState.TO_TRANSCODE | 153 | videoWithFiles.state = VideoState.TO_TRANSCODE |
151 | 154 | ||
152 | await video.save() | 155 | await videoWithFiles.save() |
153 | 156 | ||
154 | liveSession.replayVideoId = video.id | 157 | liveSession.replayVideoId = videoWithFiles.id |
155 | await liveSession.save() | 158 | await liveSession.save() |
156 | 159 | ||
157 | // Remove old HLS playlist video files | ||
158 | const videoWithFiles = await VideoModel.loadFull(video.id) | ||
159 | |||
160 | const hlsPlaylist = videoWithFiles.getHLSPlaylist() | ||
161 | await VideoFileModel.removeHLSFilesOfVideoId(hlsPlaylist.id) | 160 | await VideoFileModel.removeHLSFilesOfVideoId(hlsPlaylist.id) |
162 | 161 | ||
163 | // Reset playlist | 162 | // Reset playlist |
@@ -234,7 +233,7 @@ async function cleanupLiveAndFederate (options: { | |||
234 | 233 | ||
235 | if (streamingPlaylist) { | 234 | if (streamingPlaylist) { |
236 | if (permanentLive) { | 235 | if (permanentLive) { |
237 | await cleanupPermanentLive(video, streamingPlaylist) | 236 | await cleanupAndDestroyPermanentLive(video, streamingPlaylist) |
238 | } else { | 237 | } else { |
239 | await cleanupUnsavedNormalLive(video, streamingPlaylist) | 238 | await cleanupUnsavedNormalLive(video, streamingPlaylist) |
240 | } | 239 | } |