diff options
author | Chocobozzz <me@florianbigard.com> | 2022-06-23 10:53:16 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-06-23 10:53:16 +0200 |
commit | 64324ac646b0938e35cd88771492623b640bd0d8 (patch) | |
tree | 7d702cf4f79d5a39edcdf244d961f059d08d2105 /server/lib | |
parent | 2c2befaacaa7063df0d4557b71c187ee168a8eb6 (diff) | |
parent | b6898035bfc5ba60ec54f7e61ff832e5e2ac30eb (diff) | |
download | PeerTube-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.ts | 14 | ||||
-rw-r--r-- | server/lib/live/live-utils.ts | 10 |
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' | |||
4 | import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo, getVideoStreamDuration } from '@server/helpers/ffmpeg' | 4 | import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo, getVideoStreamDuration } 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 { cleanupNormalLive, cleanupPermanentLive, cleanupTMPLiveFiles, LiveSegmentShaStore } from '@server/lib/live' | 7 | import { cleanupUnsavedNormalLive, cleanupPermanentLive, cleanupTMPLiveFiles, LiveSegmentShaStore } from '@server/lib/live' |
8 | import { | 8 | import { |
9 | generateHLSMasterPlaylistFilename, | 9 | generateHLSMasterPlaylistFilename, |
10 | generateHlsSha256SegmentsFilename, | 10 | generateHlsSha256SegmentsFilename, |
@@ -22,15 +22,17 @@ import { VideoLiveSessionModel } from '@server/models/video/video-live-session' | |||
22 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' | 22 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' |
23 | import { MVideo, MVideoLive, MVideoLiveSession, MVideoWithAllFiles } from '@server/types/models' | 23 | import { MVideo, MVideoLive, MVideoLiveSession, MVideoWithAllFiles } from '@server/types/models' |
24 | import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' | 24 | import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' |
25 | import { logger } from '../../../helpers/logger' | 25 | import { logger, loggerTagsFactory } from '../../../helpers/logger' |
26 | |||
27 | const lTags = loggerTagsFactory('live', 'job') | ||
26 | 28 | ||
27 | async function processVideoLiveEnding (job: Job) { | 29 | async 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 | ||
13 | async function cleanupPermanentLive (video: MVideo, streamingPlaylist?: MStreamingPlaylist) { | 13 | async 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 | ||
21 | async function cleanupNormalLive (video: MVideo, streamingPlaylist?: MStreamingPlaylist) { | 21 | async 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 | ||
29 | async function cleanupTMPLiveFiles (hlsDirectory: string) { | 29 | async function cleanupTMPLiveFiles (hlsDirectory: string) { |
@@ -49,7 +49,7 @@ async function cleanupTMPLiveFiles (hlsDirectory: string) { | |||
49 | 49 | ||
50 | export { | 50 | export { |
51 | cleanupPermanentLive, | 51 | cleanupPermanentLive, |
52 | cleanupNormalLive, | 52 | cleanupUnsavedNormalLive, |
53 | cleanupTMPLiveFiles, | 53 | cleanupTMPLiveFiles, |
54 | buildConcatenatedName | 54 | buildConcatenatedName |
55 | } | 55 | } |