From 025d858e7997d6b9895fa6b7beaf23bf5ff814af Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 3 Dec 2021 14:40:29 +0100 Subject: Fix pending transcoding with failed job --- server/lib/job-queue/handlers/video-transcoding.ts | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'server/lib/job-queue/handlers/video-transcoding.ts') diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts index 0d80eb6c5..0edcdcba3 100644 --- a/server/lib/job-queue/handlers/video-transcoding.ts +++ b/server/lib/job-queue/handlers/video-transcoding.ts @@ -53,6 +53,7 @@ async function processVideoTranscoding (job: Job) { if (!handler) { await moveToFailedTranscodingState(video) + await VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode') throw new Error('Cannot find transcoding handler for ' + payload.type) } @@ -62,12 +63,20 @@ async function processVideoTranscoding (job: Job) { } catch (error) { await moveToFailedTranscodingState(video) + await VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode') + throw error } return video } +// --------------------------------------------------------------------------- + +export { + processVideoTranscoding +} + // --------------------------------------------------------------------------- // Job handlers // --------------------------------------------------------------------------- @@ -119,7 +128,7 @@ async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTrans logger.info('Merge audio transcoding job for %s ended.', video.uuid, lTags(video.uuid)) - await onVideoFileOptimizer(video, payload, 'video', user) + await onVideoFirstWebTorrentTranscoding(video, payload, 'video', user) } async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) { @@ -129,7 +138,7 @@ async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodi logger.info('Optimize transcoding job for %s ended.', video.uuid, lTags(video.uuid)) - await onVideoFileOptimizer(video, payload, transcodeType, user) + await onVideoFirstWebTorrentTranscoding(video, payload, transcodeType, user) } // --------------------------------------------------------------------------- @@ -159,7 +168,7 @@ async function onHlsPlaylistGeneration (video: MVideoFullLight, user: MUser, pay await retryTransactionWrapper(moveToNextState, video, payload.isNewVideo) } -async function onVideoFileOptimizer ( +async function onVideoFirstWebTorrentTranscoding ( videoArg: MVideoWithFile, payload: OptimizeTranscodingPayload | MergeAudioTranscodingPayload, transcodeType: TranscodeOptionsType, @@ -211,6 +220,8 @@ async function onNewWebTorrentFileResolution ( await retryTransactionWrapper(moveToNextState, video, payload.isNewVideo) } +// --------------------------------------------------------------------------- + async function createHlsJobIfEnabled (user: MUserId, payload: { videoUUID: string resolution: number @@ -241,16 +252,6 @@ async function createHlsJobIfEnabled (user: MUserId, payload: { return true } -// --------------------------------------------------------------------------- - -export { - processVideoTranscoding, - createHlsJobIfEnabled, - onNewWebTorrentFileResolution -} - -// --------------------------------------------------------------------------- - async function createLowerResolutionsJobs (options: { video: MVideoFullLight user: MUserId -- cgit v1.2.3