aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/jobs/handlers/video-file-optimizer.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-17 15:37:40 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-17 15:37:40 +0200
commit031094f7992366d8d1f6583b205f984ffadf637a (patch)
tree34ee5dc91b3e540f6f0499beadbd74575d9ad434 /server/lib/jobs/handlers/video-file-optimizer.ts
parenta6218a0b8f685078e6f7d21e9110b6418c5594fe (diff)
downloadPeerTube-031094f7992366d8d1f6583b205f984ffadf637a.tar.gz
PeerTube-031094f7992366d8d1f6583b205f984ffadf637a.tar.zst
PeerTube-031094f7992366d8d1f6583b205f984ffadf637a.zip
More robust transcoding jobs
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()