aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-06-23 10:53:16 +0200
committerChocobozzz <me@florianbigard.com>2022-06-23 10:53:16 +0200
commit64324ac646b0938e35cd88771492623b640bd0d8 (patch)
tree7d702cf4f79d5a39edcdf244d961f059d08d2105 /server/lib
parent2c2befaacaa7063df0d4557b71c187ee168a8eb6 (diff)
parentb6898035bfc5ba60ec54f7e61ff832e5e2ac30eb (diff)
downloadPeerTube-64324ac646b0938e35cd88771492623b640bd0d8.tar.gz
PeerTube-64324ac646b0938e35cd88771492623b640bd0d8.tar.zst
PeerTube-64324ac646b0938e35cd88771492623b640bd0d8.zip
Merge branch 'release/4.2.0' into develop
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/job-queue/handlers/video-live-ending.ts14
-rw-r--r--server/lib/live/live-utils.ts10
2 files changed, 12 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 feec257fc..450bda2fd 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'
4import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo, getVideoStreamDuration } from '@server/helpers/ffmpeg' 4import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo, getVideoStreamDuration } from '@server/helpers/ffmpeg'
5import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' 5import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url'
6import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' 6import { federateVideoIfNeeded } from '@server/lib/activitypub/videos'
7import { cleanupNormalLive, cleanupPermanentLive, cleanupTMPLiveFiles, LiveSegmentShaStore } from '@server/lib/live' 7import { cleanupUnsavedNormalLive, cleanupPermanentLive, cleanupTMPLiveFiles, LiveSegmentShaStore } from '@server/lib/live'
8import { 8import {
9 generateHLSMasterPlaylistFilename, 9 generateHLSMasterPlaylistFilename,
10 generateHlsSha256SegmentsFilename, 10 generateHlsSha256SegmentsFilename,
@@ -22,15 +22,17 @@ import { VideoLiveSessionModel } from '@server/models/video/video-live-session'
22import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' 22import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
23import { MVideo, MVideoLive, MVideoLiveSession, MVideoWithAllFiles } from '@server/types/models' 23import { MVideo, MVideoLive, MVideoLiveSession, MVideoWithAllFiles } from '@server/types/models'
24import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' 24import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models'
25import { logger } from '../../../helpers/logger' 25import { logger, loggerTagsFactory } from '../../../helpers/logger'
26
27const lTags = loggerTagsFactory('live', 'job')
26 28
27async function processVideoLiveEnding (job: Job) { 29async function processVideoLiveEnding (job: Job) {
28 const payload = job.data as VideoLiveEndingPayload 30 const payload = job.data as VideoLiveEndingPayload
29 31
30 logger.info('Processing video live ending for %s.', payload.videoId, { payload }) 32 logger.info('Processing video live ending for %s.', payload.videoId, { payload, ...lTags() })
31 33
32 function logError () { 34 function logError () {
33 logger.warn('Video live %d does not exist anymore. Cannot process live ending.', payload.videoId) 35 logger.warn('Video live %d does not exist anymore. Cannot process live ending.', payload.videoId, lTags())
34 } 36 }
35 37
36 const liveVideo = await VideoModel.load(payload.videoId) 38 const liveVideo = await VideoModel.load(payload.videoId)
@@ -73,8 +75,6 @@ async function saveReplayToExternalVideo (options: {
73}) { 75}) {
74 const { liveVideo, liveSession, publishedAt, replayDirectory } = options 76 const { liveVideo, liveSession, publishedAt, replayDirectory } = options
75 77
76 await cleanupTMPLiveFiles(getLiveDirectory(liveVideo))
77
78 const video = new VideoModel({ 78 const video = new VideoModel({
79 name: `${liveVideo.name} - ${new Date(publishedAt).toLocaleString()}`, 79 name: `${liveVideo.name} - ${new Date(publishedAt).toLocaleString()}`,
80 isLive: false, 80 isLive: false,
@@ -243,7 +243,7 @@ async function cleanupLiveAndFederate (options: {
243 if (live.permanentLive) { 243 if (live.permanentLive) {
244 await cleanupPermanentLive(video, streamingPlaylist) 244 await cleanupPermanentLive(video, streamingPlaylist)
245 } else { 245 } else {
246 await cleanupNormalLive(video, streamingPlaylist) 246 await cleanupUnsavedNormalLive(video, streamingPlaylist)
247 } 247 }
248 } 248 }
249 249
diff --git a/server/lib/live/live-utils.ts b/server/lib/live/live-utils.ts
index 6365e23db..6305a97a8 100644
--- a/server/lib/live/live-utils.ts
+++ b/server/lib/live/live-utils.ts
@@ -10,20 +10,20 @@ function buildConcatenatedName (segmentOrPlaylistPath: string) {
10 return 'concat-' + num[1] + '.ts' 10 return 'concat-' + num[1] + '.ts'
11} 11}
12 12
13async function cleanupPermanentLive (video: MVideo, streamingPlaylist?: MStreamingPlaylist) { 13async function cleanupPermanentLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) {
14 const hlsDirectory = getLiveDirectory(video) 14 const hlsDirectory = getLiveDirectory(video)
15 15
16 await cleanupTMPLiveFiles(hlsDirectory) 16 await cleanupTMPLiveFiles(hlsDirectory)
17 17
18 if (streamingPlaylist) await streamingPlaylist.destroy() 18 await streamingPlaylist.destroy()
19} 19}
20 20
21async function cleanupNormalLive (video: MVideo, streamingPlaylist?: MStreamingPlaylist) { 21async function cleanupUnsavedNormalLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) {
22 const hlsDirectory = getLiveDirectory(video) 22 const hlsDirectory = getLiveDirectory(video)
23 23
24 await remove(hlsDirectory) 24 await remove(hlsDirectory)
25 25
26 if (streamingPlaylist) await streamingPlaylist.destroy() 26 await streamingPlaylist.destroy()
27} 27}
28 28
29async function cleanupTMPLiveFiles (hlsDirectory: string) { 29async function cleanupTMPLiveFiles (hlsDirectory: string) {
@@ -49,7 +49,7 @@ async function cleanupTMPLiveFiles (hlsDirectory: string) {
49 49
50export { 50export {
51 cleanupPermanentLive, 51 cleanupPermanentLive,
52 cleanupNormalLive, 52 cleanupUnsavedNormalLive,
53 cleanupTMPLiveFiles, 53 cleanupTMPLiveFiles,
54 buildConcatenatedName 54 buildConcatenatedName
55} 55}