aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorkontrollanten <6680299+kontrollanten@users.noreply.github.com>2021-11-08 04:20:04 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-11-09 15:00:21 +0100
commit4e29f4fe23b413cc8c55ac0d8373f36bcd60b47a (patch)
treec9e63dac52672d46cbf0072dc35e396dca61079c
parent9c391612038cd48cfeb2315dcbb8feddcf877d94 (diff)
downloadPeerTube-4e29f4fe23b413cc8c55ac0d8373f36bcd60b47a.tar.gz
PeerTube-4e29f4fe23b413cc8c55ac0d8373f36bcd60b47a.tar.zst
PeerTube-4e29f4fe23b413cc8c55ac0d8373f36bcd60b47a.zip
video: add video stranscoding_failed state
-rw-r--r--server/initializers/constants.ts3
-rw-r--r--server/lib/job-queue/handlers/video-transcoding.ts11
-rw-r--r--server/lib/video-state.ts7
-rw-r--r--shared/models/videos/video-state.enum.ts3
4 files changed, 20 insertions, 4 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index fb6bc9a66..845576667 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -420,7 +420,8 @@ const VIDEO_STATES: { [ id in VideoState ]: string } = {
420 [VideoState.TO_IMPORT]: 'To import', 420 [VideoState.TO_IMPORT]: 'To import',
421 [VideoState.WAITING_FOR_LIVE]: 'Waiting for livestream', 421 [VideoState.WAITING_FOR_LIVE]: 'Waiting for livestream',
422 [VideoState.LIVE_ENDED]: 'Livestream ended', 422 [VideoState.LIVE_ENDED]: 'Livestream ended',
423 [VideoState.TO_MOVE_TO_EXTERNAL_STORAGE]: 'To move to an external storage' 423 [VideoState.TO_MOVE_TO_EXTERNAL_STORAGE]: 'To move to an external storage',
424 [VideoState.TRANSCODING_FAILED]: 'Transcoding failed'
424} 425}
425 426
426const VIDEO_IMPORT_STATES: { [ id in VideoImportState ]: string } = { 427const VIDEO_IMPORT_STATES: { [ id in VideoImportState ]: string } = {
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'
2import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' 2import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils'
3import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' 3import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video'
4import { VideoPathManager } from '@server/lib/video-path-manager' 4import { VideoPathManager } from '@server/lib/video-path-manager'
5import { moveToNextState } from '@server/lib/video-state' 5import { moveToFailedState, moveToNextState } from '@server/lib/video-state'
6import { UserModel } from '@server/models/user/user' 6import { UserModel } from '@server/models/user/user'
7import { VideoJobInfoModel } from '@server/models/video/video-job-info' 7import { VideoJobInfoModel } from '@server/models/video/video-job-info'
8import { MUser, MUserId, MVideo, MVideoFullLight, MVideoWithFile } from '@server/types/models' 8import { 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
82function 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
84export { 90export {
85 buildNextVideoState, 91 buildNextVideoState,
86 moveToExternalStorageState, 92 moveToExternalStorageState,
93 moveToFailedState,
87 moveToNextState 94 moveToNextState
88} 95}
89 96
diff --git a/shared/models/videos/video-state.enum.ts b/shared/models/videos/video-state.enum.ts
index c6af481e7..6112b6e16 100644
--- a/shared/models/videos/video-state.enum.ts
+++ b/shared/models/videos/video-state.enum.ts
@@ -4,5 +4,6 @@ export const enum VideoState {
4 TO_IMPORT = 3, 4 TO_IMPORT = 3,
5 WAITING_FOR_LIVE = 4, 5 WAITING_FOR_LIVE = 4,
6 LIVE_ENDED = 5, 6 LIVE_ENDED = 5,
7 TO_MOVE_TO_EXTERNAL_STORAGE = 6 7 TO_MOVE_TO_EXTERNAL_STORAGE = 6,
8 TRANSCODING_FAILED = 7
8} 9}