From 031094f7992366d8d1f6583b205f984ffadf637a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 17 Oct 2017 15:37:40 +0200 Subject: More robust transcoding jobs --- server/lib/jobs/handlers/video-file-transcoder.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'server/lib/jobs/handlers/video-file-transcoder.ts') diff --git a/server/lib/jobs/handlers/video-file-transcoder.ts b/server/lib/jobs/handlers/video-file-transcoder.ts index 0e45b4dca..0dafee566 100644 --- a/server/lib/jobs/handlers/video-file-transcoder.ts +++ b/server/lib/jobs/handlers/video-file-transcoder.ts @@ -4,8 +4,14 @@ import { logger } from '../../../helpers' import { VideoInstance } from '../../../models' import { VideoResolution } from '../../../../shared' -function process (data: { videoUUID: string, resolution: VideoResolution }) { +function process (data: { videoUUID: string, resolution: VideoResolution }, jobId: number) { return db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(data.videoUUID).then(video => { + // No video, maybe deleted? + if (!video) { + logger.info('Do not process job %d, video does not exist.', jobId, { videoUUID: video.uuid }) + return undefined + } + return video.transcodeOriginalVideofile(data.resolution).then(() => video) }) } @@ -16,6 +22,8 @@ function onError (err: Error, jobId: number) { } function onSuccess (jobId: number, video: VideoInstance) { + if (video === undefined) return undefined + logger.info('Job %d is a success.', jobId) const remoteVideo = video.toUpdateRemoteJSON() -- cgit v1.2.3