]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/jobs/handlers/video-file-transcoder.ts
More robust transcoding jobs
[github/Chocobozzz/PeerTube.git] / server / lib / jobs / handlers / video-file-transcoder.ts
index 0e45b4dca510e60196935e4a72455b34f171e8d5..0dafee566a08639cfb65f4d86d26853fb68bcd35 100644 (file)
@@ -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()