diff options
Diffstat (limited to 'server/lib/job-queue/handlers/video-file.ts')
-rw-r--r-- | server/lib/job-queue/handlers/video-file.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/server/lib/job-queue/handlers/video-file.ts b/server/lib/job-queue/handlers/video-file.ts index c6308f7a6..1463c93fc 100644 --- a/server/lib/job-queue/handlers/video-file.ts +++ b/server/lib/job-queue/handlers/video-file.ts | |||
@@ -8,6 +8,7 @@ import { retryTransactionWrapper } from '../../../helpers/database-utils' | |||
8 | import { sequelizeTypescript } from '../../../initializers' | 8 | import { sequelizeTypescript } from '../../../initializers' |
9 | import * as Bluebird from 'bluebird' | 9 | import * as Bluebird from 'bluebird' |
10 | import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' | 10 | import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' |
11 | import { importVideoFile, transcodeOriginalVideofile, optimizeOriginalVideofile } from '../../video-transcoding' | ||
11 | 12 | ||
12 | export type VideoFilePayload = { | 13 | export type VideoFilePayload = { |
13 | videoUUID: string | 14 | videoUUID: string |
@@ -25,14 +26,14 @@ async function processVideoFileImport (job: Bull.Job) { | |||
25 | const payload = job.data as VideoFileImportPayload | 26 | const payload = job.data as VideoFileImportPayload |
26 | logger.info('Processing video file import in job %d.', job.id) | 27 | logger.info('Processing video file import in job %d.', job.id) |
27 | 28 | ||
28 | const video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(payload.videoUUID) | 29 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID) |
29 | // No video, maybe deleted? | 30 | // No video, maybe deleted? |
30 | if (!video) { | 31 | if (!video) { |
31 | logger.info('Do not process job %d, video does not exist.', job.id) | 32 | logger.info('Do not process job %d, video does not exist.', job.id) |
32 | return undefined | 33 | return undefined |
33 | } | 34 | } |
34 | 35 | ||
35 | await video.importVideoFile(payload.filePath) | 36 | await importVideoFile(video, payload.filePath) |
36 | 37 | ||
37 | await onVideoFileTranscoderOrImportSuccess(video) | 38 | await onVideoFileTranscoderOrImportSuccess(video) |
38 | return video | 39 | return video |
@@ -42,7 +43,7 @@ async function processVideoFile (job: Bull.Job) { | |||
42 | const payload = job.data as VideoFilePayload | 43 | const payload = job.data as VideoFilePayload |
43 | logger.info('Processing video file in job %d.', job.id) | 44 | logger.info('Processing video file in job %d.', job.id) |
44 | 45 | ||
45 | const video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(payload.videoUUID) | 46 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID) |
46 | // No video, maybe deleted? | 47 | // No video, maybe deleted? |
47 | if (!video) { | 48 | if (!video) { |
48 | logger.info('Do not process job %d, video does not exist.', job.id) | 49 | logger.info('Do not process job %d, video does not exist.', job.id) |
@@ -51,11 +52,11 @@ async function processVideoFile (job: Bull.Job) { | |||
51 | 52 | ||
52 | // Transcoding in other resolution | 53 | // Transcoding in other resolution |
53 | if (payload.resolution) { | 54 | if (payload.resolution) { |
54 | await video.transcodeOriginalVideofile(payload.resolution, payload.isPortraitMode || false) | 55 | await transcodeOriginalVideofile(video, payload.resolution, payload.isPortraitMode || false) |
55 | 56 | ||
56 | await retryTransactionWrapper(onVideoFileTranscoderOrImportSuccess, video) | 57 | await retryTransactionWrapper(onVideoFileTranscoderOrImportSuccess, video) |
57 | } else { | 58 | } else { |
58 | await video.optimizeOriginalVideofile() | 59 | await optimizeOriginalVideofile(video) |
59 | 60 | ||
60 | await retryTransactionWrapper(onVideoFileOptimizerSuccess, video, payload.isNewVideo) | 61 | await retryTransactionWrapper(onVideoFileOptimizerSuccess, video, payload.isNewVideo) |
61 | } | 62 | } |
@@ -68,7 +69,7 @@ async function onVideoFileTranscoderOrImportSuccess (video: VideoModel) { | |||
68 | 69 | ||
69 | return sequelizeTypescript.transaction(async t => { | 70 | return sequelizeTypescript.transaction(async t => { |
70 | // Maybe the video changed in database, refresh it | 71 | // Maybe the video changed in database, refresh it |
71 | let videoDatabase = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(video.uuid, t) | 72 | let videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t) |
72 | // Video does not exist anymore | 73 | // Video does not exist anymore |
73 | if (!videoDatabase) return undefined | 74 | if (!videoDatabase) return undefined |
74 | 75 | ||
@@ -98,7 +99,7 @@ async function onVideoFileOptimizerSuccess (video: VideoModel, isNewVideo: boole | |||
98 | 99 | ||
99 | return sequelizeTypescript.transaction(async t => { | 100 | return sequelizeTypescript.transaction(async t => { |
100 | // Maybe the video changed in database, refresh it | 101 | // Maybe the video changed in database, refresh it |
101 | const videoDatabase = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(video.uuid, t) | 102 | const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t) |
102 | // Video does not exist anymore | 103 | // Video does not exist anymore |
103 | if (!videoDatabase) return undefined | 104 | if (!videoDatabase) return undefined |
104 | 105 | ||