video: add video stranscoding_failed state
This commit is contained in:
parent
9c39161203
commit
4e29f4fe23
|
@ -420,7 +420,8 @@ const VIDEO_STATES: { [ id in VideoState ]: string } = {
|
||||||
[VideoState.TO_IMPORT]: 'To import',
|
[VideoState.TO_IMPORT]: 'To import',
|
||||||
[VideoState.WAITING_FOR_LIVE]: 'Waiting for livestream',
|
[VideoState.WAITING_FOR_LIVE]: 'Waiting for livestream',
|
||||||
[VideoState.LIVE_ENDED]: 'Livestream ended',
|
[VideoState.LIVE_ENDED]: 'Livestream ended',
|
||||||
[VideoState.TO_MOVE_TO_EXTERNAL_STORAGE]: 'To move to an external storage'
|
[VideoState.TO_MOVE_TO_EXTERNAL_STORAGE]: 'To move to an external storage',
|
||||||
|
[VideoState.TRANSCODING_FAILED]: 'Transcoding failed'
|
||||||
}
|
}
|
||||||
|
|
||||||
const VIDEO_IMPORT_STATES: { [ id in VideoImportState ]: string } = {
|
const VIDEO_IMPORT_STATES: { [ id in VideoImportState ]: string } = {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Job } from 'bull'
|
||||||
import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils'
|
import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils'
|
||||||
import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video'
|
import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video'
|
||||||
import { VideoPathManager } from '@server/lib/video-path-manager'
|
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 { UserModel } from '@server/models/user/user'
|
||||||
import { VideoJobInfoModel } from '@server/models/video/video-job-info'
|
import { VideoJobInfoModel } from '@server/models/video/video-job-info'
|
||||||
import { MUser, MUserId, MVideo, MVideoFullLight, MVideoWithFile } from '@server/types/models'
|
import { MUser, MUserId, MVideo, MVideoFullLight, MVideoWithFile } from '@server/types/models'
|
||||||
|
@ -52,10 +52,17 @@ async function processVideoTranscoding (job: Job) {
|
||||||
const handler = handlers[payload.type]
|
const handler = handlers[payload.type]
|
||||||
|
|
||||||
if (!handler) {
|
if (!handler) {
|
||||||
|
await moveToFailedState(video)
|
||||||
throw new Error('Cannot find transcoding handler for ' + payload.type)
|
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
|
return video
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,11 +79,18 @@ async function moveToExternalStorageState (video: MVideoFullLight, isNewVideo: b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function moveToFailedState (video: MVideoFullLight) {
|
||||||
|
return sequelizeTypescript.transaction(async t => {
|
||||||
|
await video.setNewState(VideoState.TRANSCODING_FAILED, false, t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
export {
|
export {
|
||||||
buildNextVideoState,
|
buildNextVideoState,
|
||||||
moveToExternalStorageState,
|
moveToExternalStorageState,
|
||||||
|
moveToFailedState,
|
||||||
moveToNextState
|
moveToNextState
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,5 +4,6 @@ export const enum VideoState {
|
||||||
TO_IMPORT = 3,
|
TO_IMPORT = 3,
|
||||||
WAITING_FOR_LIVE = 4,
|
WAITING_FOR_LIVE = 4,
|
||||||
LIVE_ENDED = 5,
|
LIVE_ENDED = 5,
|
||||||
TO_MOVE_TO_EXTERNAL_STORAGE = 6
|
TO_MOVE_TO_EXTERNAL_STORAGE = 6,
|
||||||
|
TRANSCODING_FAILED = 7
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue