1
0
Fork 0

video: add video stranscoding_failed state

This commit is contained in:
kontrollanten 2021-11-08 04:20:04 +01:00 committed by Chocobozzz
parent 9c39161203
commit 4e29f4fe23
4 changed files with 20 additions and 4 deletions

View File

@ -420,7 +420,8 @@ const VIDEO_STATES: { [ id in VideoState ]: string } = {
[VideoState.TO_IMPORT]: 'To import',
[VideoState.WAITING_FOR_LIVE]: 'Waiting for livestream',
[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 } = {

View File

@ -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
}

View File

@ -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 {
buildNextVideoState,
moveToExternalStorageState,
moveToFailedState,
moveToNextState
}

View File

@ -4,5 +4,6 @@ export const enum VideoState {
TO_IMPORT = 3,
WAITING_FOR_LIVE = 4,
LIVE_ENDED = 5,
TO_MOVE_TO_EXTERNAL_STORAGE = 6
TO_MOVE_TO_EXTERNAL_STORAGE = 6,
TRANSCODING_FAILED = 7
}