diff options
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/job-queue/handlers/video-transcoding.ts | 11 | ||||
-rw-r--r-- | server/lib/video-state.ts | 7 |
2 files changed, 16 insertions, 2 deletions
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' | |||
2 | import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' | 2 | import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' |
3 | import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' | 3 | import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' |
4 | import { VideoPathManager } from '@server/lib/video-path-manager' | 4 | import { VideoPathManager } from '@server/lib/video-path-manager' |
5 | import { moveToNextState } from '@server/lib/video-state' | 5 | import { moveToFailedState, moveToNextState } from '@server/lib/video-state' |
6 | import { UserModel } from '@server/models/user/user' | 6 | import { UserModel } from '@server/models/user/user' |
7 | import { VideoJobInfoModel } from '@server/models/video/video-job-info' | 7 | import { VideoJobInfoModel } from '@server/models/video/video-job-info' |
8 | import { MUser, MUserId, MVideo, MVideoFullLight, MVideoWithFile } from '@server/types/models' | 8 | import { MUser, MUserId, MVideo, MVideoFullLight, MVideoWithFile } from '@server/types/models' |
@@ -52,10 +52,17 @@ async function processVideoTranscoding (job: Job) { | |||
52 | const handler = handlers[payload.type] | 52 | const handler = handlers[payload.type] |
53 | 53 | ||
54 | if (!handler) { | 54 | if (!handler) { |
55 | await moveToFailedState(video) | ||
55 | throw new Error('Cannot find transcoding handler for ' + payload.type) | 56 | throw new Error('Cannot find transcoding handler for ' + payload.type) |
56 | } | 57 | } |
57 | 58 | ||
58 | await handler(job, payload, video, user) | 59 | try { |
60 | await handler(job, payload, video, user) | ||
61 | } catch (error) { | ||
62 | await moveToFailedState(video) | ||
63 | |||
64 | throw error | ||
65 | } | ||
59 | 66 | ||
60 | return video | 67 | return video |
61 | } | 68 | } |
diff --git a/server/lib/video-state.ts b/server/lib/video-state.ts index d5bbbec43..2260e90f5 100644 --- a/server/lib/video-state.ts +++ b/server/lib/video-state.ts | |||
@@ -79,11 +79,18 @@ async function moveToExternalStorageState (video: MVideoFullLight, isNewVideo: b | |||
79 | } | 79 | } |
80 | } | 80 | } |
81 | 81 | ||
82 | function moveToFailedState (video: MVideoFullLight) { | ||
83 | return sequelizeTypescript.transaction(async t => { | ||
84 | await video.setNewState(VideoState.TRANSCODING_FAILED, false, t) | ||
85 | }) | ||
86 | } | ||
87 | |||
82 | // --------------------------------------------------------------------------- | 88 | // --------------------------------------------------------------------------- |
83 | 89 | ||
84 | export { | 90 | export { |
85 | buildNextVideoState, | 91 | buildNextVideoState, |
86 | moveToExternalStorageState, | 92 | moveToExternalStorageState, |
93 | moveToFailedState, | ||
87 | moveToNextState | 94 | moveToNextState |
88 | } | 95 | } |
89 | 96 | ||