From 8ebf2a5d5d126e6ef9b89109124adf2a5e9e293d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 16 Jun 2021 15:14:41 +0200 Subject: Refactor live manager --- server/lib/job-queue/handlers/video-live-ending.ts | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 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 517b90abc..9eba41bf8 100644 --- a/server/lib/job-queue/handlers/video-live-ending.ts +++ b/server/lib/job-queue/handlers/video-live-ending.ts @@ -3,7 +3,7 @@ import { pathExists, readdir, remove } from 'fs-extra' import { join } from 'path' import { ffprobePromise, getAudioStream, getDurationFromVideoFile, getVideoFileResolution } from '@server/helpers/ffprobe-utils' import { VIDEO_LIVE } from '@server/initializers/constants' -import { LiveManager } from '@server/lib/live-manager' +import { buildConcatenatedName, cleanupLive, LiveSegmentShaStore } from '@server/lib/live' import { generateVideoMiniature } from '@server/lib/thumbnail' import { generateHlsPlaylistResolutionFromTS } from '@server/lib/transcoding/video-transcoding' import { publishAndFederateIfNeeded } from '@server/lib/video' @@ -12,7 +12,7 @@ import { VideoModel } from '@server/models/video/video' import { VideoFileModel } from '@server/models/video/video-file' import { VideoLiveModel } from '@server/models/video/video-live' import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' -import { MStreamingPlaylist, MVideo, MVideoLive } from '@server/types/models' +import { MVideo, MVideoLive } from '@server/types/models' import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' import { logger } from '../../../helpers/logger' @@ -37,7 +37,7 @@ async function processVideoLiveEnding (job: Bull.Job) { return } - LiveManager.Instance.cleanupShaSegments(video.uuid) + LiveSegmentShaStore.Instance.cleanupShaSegments(video.uuid) if (live.saveReplay !== true) { return cleanupLive(video, streamingPlaylist) @@ -46,19 +46,10 @@ async function processVideoLiveEnding (job: Bull.Job) { return saveLive(video, live) } -async function cleanupLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) { - const hlsDirectory = getHLSDirectory(video) - - await remove(hlsDirectory) - - await streamingPlaylist.destroy() -} - // --------------------------------------------------------------------------- export { - processVideoLiveEnding, - cleanupLive + processVideoLiveEnding } // --------------------------------------------------------------------------- @@ -94,7 +85,7 @@ async function saveLive (video: MVideo, live: MVideoLive) { let durationDone = false for (const playlistFile of playlistFiles) { - const concatenatedTsFile = LiveManager.Instance.buildConcatenatedName(playlistFile) + const concatenatedTsFile = buildConcatenatedName(playlistFile) const concatenatedTsFilePath = join(replayDirectory, concatenatedTsFile) const probe = await ffprobePromise(concatenatedTsFilePath) -- cgit v1.2.3