]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/jobs/handlers/video-file-transcoder.ts
Use async/await in lib and initializers
[github/Chocobozzz/PeerTube.git] / server / lib / jobs / handlers / video-file-transcoder.ts
index 0dafee566a08639cfb65f4d86d26853fb68bcd35..b240ff58af52def8faa5aaa4ae9b28f2d4ce68cc 100644 (file)
@@ -4,16 +4,17 @@ import { logger } from '../../../helpers'
 import { VideoInstance } from '../../../models'
 import { VideoResolution } from '../../../../shared'
 
-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)
-  })
+async function process (data: { videoUUID: string, resolution: VideoResolution }, jobId: number) {
+  const video = await db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(data.videoUUID)
+  // No video, maybe deleted?
+  if (!video) {
+    logger.info('Do not process job %d, video does not exist.', jobId, { videoUUID: video.uuid })
+    return undefined
+  }
+
+  await video.transcodeOriginalVideofile(data.resolution)
+
+  return video
 }
 
 function onError (err: Error, jobId: number) {