diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-10-17 15:37:40 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-10-17 15:37:40 +0200 |
commit | 031094f7992366d8d1f6583b205f984ffadf637a (patch) | |
tree | 34ee5dc91b3e540f6f0499beadbd74575d9ad434 /server/lib/jobs/handlers/video-file-transcoder.ts | |
parent | a6218a0b8f685078e6f7d21e9110b6418c5594fe (diff) | |
download | PeerTube-031094f7992366d8d1f6583b205f984ffadf637a.tar.gz PeerTube-031094f7992366d8d1f6583b205f984ffadf637a.tar.zst PeerTube-031094f7992366d8d1f6583b205f984ffadf637a.zip |
More robust transcoding jobs
Diffstat (limited to 'server/lib/jobs/handlers/video-file-transcoder.ts')
-rw-r--r-- | server/lib/jobs/handlers/video-file-transcoder.ts | 10 |
1 files changed, 9 insertions, 1 deletions
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' | |||
4 | import { VideoInstance } from '../../../models' | 4 | import { VideoInstance } from '../../../models' |
5 | import { VideoResolution } from '../../../../shared' | 5 | import { VideoResolution } from '../../../../shared' |
6 | 6 | ||
7 | function process (data: { videoUUID: string, resolution: VideoResolution }) { | 7 | function process (data: { videoUUID: string, resolution: VideoResolution }, jobId: number) { |
8 | return db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(data.videoUUID).then(video => { | 8 | return db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(data.videoUUID).then(video => { |
9 | // No video, maybe deleted? | ||
10 | if (!video) { | ||
11 | logger.info('Do not process job %d, video does not exist.', jobId, { videoUUID: video.uuid }) | ||
12 | return undefined | ||
13 | } | ||
14 | |||
9 | return video.transcodeOriginalVideofile(data.resolution).then(() => video) | 15 | return video.transcodeOriginalVideofile(data.resolution).then(() => video) |
10 | }) | 16 | }) |
11 | } | 17 | } |
@@ -16,6 +22,8 @@ function onError (err: Error, jobId: number) { | |||
16 | } | 22 | } |
17 | 23 | ||
18 | function onSuccess (jobId: number, video: VideoInstance) { | 24 | function onSuccess (jobId: number, video: VideoInstance) { |
25 | if (video === undefined) return undefined | ||
26 | |||
19 | logger.info('Job %d is a success.', jobId) | 27 | logger.info('Job %d is a success.', jobId) |
20 | 28 | ||
21 | const remoteVideo = video.toUpdateRemoteJSON() | 29 | const remoteVideo = video.toUpdateRemoteJSON() |