aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/jobs/handlers/video-file-optimizer.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/jobs/handlers/video-file-optimizer.ts')
-rw-r--r--server/lib/jobs/handlers/video-file-optimizer.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/server/lib/jobs/handlers/video-file-optimizer.ts b/server/lib/jobs/handlers/video-file-optimizer.ts
index a87ce52dc..63a51064c 100644
--- a/server/lib/jobs/handlers/video-file-optimizer.ts
+++ b/server/lib/jobs/handlers/video-file-optimizer.ts
@@ -6,8 +6,14 @@ import { VideoInstance } from '../../../models'
6import { addVideoToFriends } from '../../friends' 6import { addVideoToFriends } from '../../friends'
7import { JobScheduler } from '../job-scheduler' 7import { JobScheduler } from '../job-scheduler'
8 8
9function process (data: { videoUUID: string }) { 9function process (data: { videoUUID: string }, jobId: number) {
10 return db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(data.videoUUID).then(video => { 10 return db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(data.videoUUID).then(video => {
11 // No video, maybe deleted?
12 if (!video) {
13 logger.info('Do not process job %d, video does not exist.', jobId, { videoUUID: video.uuid })
14 return undefined
15 }
16
11 return video.optimizeOriginalVideofile().then(() => video) 17 return video.optimizeOriginalVideofile().then(() => video)
12 }) 18 })
13} 19}
@@ -18,6 +24,8 @@ function onError (err: Error, jobId: number) {
18} 24}
19 25
20function onSuccess (jobId: number, video: VideoInstance) { 26function onSuccess (jobId: number, video: VideoInstance) {
27 if (video === undefined) return undefined
28
21 logger.info('Job %d is a success.', jobId) 29 logger.info('Job %d is a success.', jobId)
22 30
23 video.toAddRemoteJSON() 31 video.toAddRemoteJSON()