diff options
Diffstat (limited to 'server/lib/jobs/handlers/video-transcoder.ts')
-rw-r--r-- | server/lib/jobs/handlers/video-transcoder.ts | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/server/lib/jobs/handlers/video-transcoder.ts b/server/lib/jobs/handlers/video-transcoder.ts index 6f606a7d3..e829ca813 100644 --- a/server/lib/jobs/handlers/video-transcoder.ts +++ b/server/lib/jobs/handlers/video-transcoder.ts | |||
@@ -3,29 +3,23 @@ import { logger } from '../../../helpers' | |||
3 | import { addVideoToFriends } from '../../../lib' | 3 | import { addVideoToFriends } from '../../../lib' |
4 | import { VideoInstance } from '../../../models' | 4 | import { VideoInstance } from '../../../models' |
5 | 5 | ||
6 | function process (data: { id: string }, callback: (err: Error, videoInstance?: VideoInstance) => void) { | 6 | function process (data: { id: string }) { |
7 | db.Video.loadAndPopulateAuthorAndPodAndTags(data.id, function (err, video) { | 7 | return db.Video.loadAndPopulateAuthorAndPodAndTags(data.id).then(video => { |
8 | if (err) return callback(err) | 8 | return video.transcodeVideofile().then(() => video) |
9 | |||
10 | video.transcodeVideofile(function (err) { | ||
11 | return callback(err, video) | ||
12 | }) | ||
13 | }) | 9 | }) |
14 | } | 10 | } |
15 | 11 | ||
16 | function onError (err: Error, jobId: number, video: VideoInstance, callback: (err: Error) => void) { | 12 | function onError (err: Error, jobId: number) { |
17 | logger.error('Error when transcoding video file in job %d.', jobId, { error: err }) | 13 | logger.error('Error when transcoding video file in job %d.', jobId, { error: err }) |
18 | return callback(null) | 14 | return Promise.resolve() |
19 | } | 15 | } |
20 | 16 | ||
21 | function onSuccess (data: any, jobId: number, video: VideoInstance, callback: (err: Error) => void) { | 17 | function onSuccess (jobId: number, video: VideoInstance) { |
22 | logger.info('Job %d is a success.', jobId) | 18 | logger.info('Job %d is a success.', jobId) |
23 | 19 | ||
24 | video.toAddRemoteJSON(function (err, remoteVideo) { | 20 | video.toAddRemoteJSON().then(remoteVideo => { |
25 | if (err) return callback(err) | ||
26 | |||
27 | // Now we'll add the video's meta data to our friends | 21 | // Now we'll add the video's meta data to our friends |
28 | addVideoToFriends(remoteVideo, null, callback) | 22 | return addVideoToFriends(remoteVideo, null) |
29 | }) | 23 | }) |
30 | } | 24 | } |
31 | 25 | ||