From 4e29f4fe23b413cc8c55ac0d8373f36bcd60b47a Mon Sep 17 00:00:00 2001 From: kontrollanten <6680299+kontrollanten@users.noreply.github.com> Date: Mon, 8 Nov 2021 04:20:04 +0100 Subject: video: add video stranscoding_failed state --- server/lib/job-queue/handlers/video-transcoding.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'server/lib/job-queue/handlers') diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts index 20880cdc1..b280a1cc9 100644 --- a/server/lib/job-queue/handlers/video-transcoding.ts +++ b/server/lib/job-queue/handlers/video-transcoding.ts @@ -2,7 +2,7 @@ import { Job } from 'bull' import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' import { VideoPathManager } from '@server/lib/video-path-manager' -import { moveToNextState } from '@server/lib/video-state' +import { moveToFailedState, moveToNextState } from '@server/lib/video-state' import { UserModel } from '@server/models/user/user' import { VideoJobInfoModel } from '@server/models/video/video-job-info' import { MUser, MUserId, MVideo, MVideoFullLight, MVideoWithFile } from '@server/types/models' @@ -52,10 +52,17 @@ async function processVideoTranscoding (job: Job) { const handler = handlers[payload.type] if (!handler) { + await moveToFailedState(video) throw new Error('Cannot find transcoding handler for ' + payload.type) } - await handler(job, payload, video, user) + try { + await handler(job, payload, video, user) + } catch (error) { + await moveToFailedState(video) + + throw error + } return video } -- cgit v1.2.3