aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/jobs/transcoding-job-scheduler
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/jobs/transcoding-job-scheduler')
-rw-r--r--server/lib/jobs/transcoding-job-scheduler/transcoding-job-scheduler.ts5
-rw-r--r--server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts16
-rw-r--r--server/lib/jobs/transcoding-job-scheduler/video-file-transcoder-handler.ts11
3 files changed, 16 insertions, 16 deletions
diff --git a/server/lib/jobs/transcoding-job-scheduler/transcoding-job-scheduler.ts b/server/lib/jobs/transcoding-job-scheduler/transcoding-job-scheduler.ts
index c5efe8eeb..e5530a73c 100644
--- a/server/lib/jobs/transcoding-job-scheduler/transcoding-job-scheduler.ts
+++ b/server/lib/jobs/transcoding-job-scheduler/transcoding-job-scheduler.ts
@@ -1,14 +1,15 @@
1import { JobCategory } from '../../../../shared' 1import { JobCategory } from '../../../../shared'
2import { VideoModel } from '../../../models/video/video'
2import { JobHandler, JobScheduler } from '../job-scheduler' 3import { JobHandler, JobScheduler } from '../job-scheduler'
4
3import * as videoFileOptimizer from './video-file-optimizer-handler' 5import * as videoFileOptimizer from './video-file-optimizer-handler'
4import * as videoFileTranscoder from './video-file-transcoder-handler' 6import * as videoFileTranscoder from './video-file-transcoder-handler'
5import { VideoInstance } from '../../../models/video/video-interface'
6 7
7type TranscodingJobPayload = { 8type TranscodingJobPayload = {
8 videoUUID: string 9 videoUUID: string
9 resolution?: number 10 resolution?: number
10} 11}
11const jobHandlers: { [ handlerName: string ]: JobHandler<TranscodingJobPayload, VideoInstance> } = { 12const jobHandlers: { [ handlerName: string ]: JobHandler<TranscodingJobPayload, VideoModel> } = {
12 videoFileOptimizer, 13 videoFileOptimizer,
13 videoFileTranscoder 14 videoFileTranscoder
14} 15}
diff --git a/server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts b/server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts
index e65ab3ee1..1786ce971 100644
--- a/server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts
+++ b/server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts
@@ -1,14 +1,14 @@
1import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
2import { computeResolutionsToTranscode, logger } from '../../../helpers' 2import { computeResolutionsToTranscode, logger } from '../../../helpers'
3import { database as db } from '../../../initializers/database' 3import { sequelizeTypescript } from '../../../initializers'
4import { VideoInstance } from '../../../models' 4import { VideoModel } from '../../../models/video/video'
5import { sendAddVideo } from '../../activitypub/send/send-add' 5import { shareVideoByServer } from '../../activitypub'
6import { sendAddVideo } from '../../activitypub/send'
6import { JobScheduler } from '../job-scheduler' 7import { JobScheduler } from '../job-scheduler'
7import { TranscodingJobPayload } from './transcoding-job-scheduler' 8import { TranscodingJobPayload } from './transcoding-job-scheduler'
8import { shareVideoByServer } from '../../activitypub/share'
9 9
10async function process (data: TranscodingJobPayload, jobId: number) { 10async function process (data: TranscodingJobPayload, jobId: number) {
11 const video = await db.Video.loadByUUIDAndPopulateAccountAndServerAndTags(data.videoUUID) 11 const video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(data.videoUUID)
12 // No video, maybe deleted? 12 // No video, maybe deleted?
13 if (!video) { 13 if (!video) {
14 logger.info('Do not process job %d, video does not exist.', jobId, { videoUUID: video.uuid }) 14 logger.info('Do not process job %d, video does not exist.', jobId, { videoUUID: video.uuid })
@@ -25,13 +25,13 @@ function onError (err: Error, jobId: number) {
25 return Promise.resolve() 25 return Promise.resolve()
26} 26}
27 27
28async function onSuccess (jobId: number, video: VideoInstance, jobScheduler: JobScheduler<TranscodingJobPayload, VideoInstance>) { 28async function onSuccess (jobId: number, video: VideoModel, jobScheduler: JobScheduler<TranscodingJobPayload, VideoModel>) {
29 if (video === undefined) return undefined 29 if (video === undefined) return undefined
30 30
31 logger.info('Job %d is a success.', jobId) 31 logger.info('Job %d is a success.', jobId)
32 32
33 // Maybe the video changed in database, refresh it 33 // Maybe the video changed in database, refresh it
34 const videoDatabase = await db.Video.loadByUUIDAndPopulateAccountAndServerAndTags(video.uuid) 34 const videoDatabase = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(video.uuid)
35 // Video does not exist anymore 35 // Video does not exist anymore
36 if (!videoDatabase) return undefined 36 if (!videoDatabase) return undefined
37 37
@@ -50,7 +50,7 @@ async function onSuccess (jobId: number, video: VideoInstance, jobScheduler: Job
50 50
51 if (resolutionsEnabled.length !== 0) { 51 if (resolutionsEnabled.length !== 0) {
52 try { 52 try {
53 await db.sequelize.transaction(async t => { 53 await sequelizeTypescript.transaction(async t => {
54 const tasks: Bluebird<any>[] = [] 54 const tasks: Bluebird<any>[] = []
55 55
56 for (const resolution of resolutionsEnabled) { 56 for (const resolution of resolutionsEnabled) {
diff --git a/server/lib/jobs/transcoding-job-scheduler/video-file-transcoder-handler.ts b/server/lib/jobs/transcoding-job-scheduler/video-file-transcoder-handler.ts
index 867580200..8957b4565 100644
--- a/server/lib/jobs/transcoding-job-scheduler/video-file-transcoder-handler.ts
+++ b/server/lib/jobs/transcoding-job-scheduler/video-file-transcoder-handler.ts
@@ -1,11 +1,10 @@
1import { VideoResolution } from '../../../../shared' 1import { VideoResolution } from '../../../../shared'
2import { logger } from '../../../helpers' 2import { logger } from '../../../helpers'
3import { database as db } from '../../../initializers/database' 3import { VideoModel } from '../../../models/video/video'
4import { VideoInstance } from '../../../models' 4import { sendUpdateVideo } from '../../activitypub/send'
5import { sendUpdateVideo } from '../../activitypub/send/send-update'
6 5
7async function process (data: { videoUUID: string, resolution: VideoResolution }, jobId: number) { 6async function process (data: { videoUUID: string, resolution: VideoResolution }, jobId: number) {
8 const video = await db.Video.loadByUUIDAndPopulateAccountAndServerAndTags(data.videoUUID) 7 const video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(data.videoUUID)
9 // No video, maybe deleted? 8 // No video, maybe deleted?
10 if (!video) { 9 if (!video) {
11 logger.info('Do not process job %d, video does not exist.', jobId, { videoUUID: video.uuid }) 10 logger.info('Do not process job %d, video does not exist.', jobId, { videoUUID: video.uuid })
@@ -22,13 +21,13 @@ function onError (err: Error, jobId: number) {
22 return Promise.resolve() 21 return Promise.resolve()
23} 22}
24 23
25async function onSuccess (jobId: number, video: VideoInstance) { 24async function onSuccess (jobId: number, video: VideoModel) {
26 if (video === undefined) return undefined 25 if (video === undefined) return undefined
27 26
28 logger.info('Job %d is a success.', jobId) 27 logger.info('Job %d is a success.', jobId)
29 28
30 // Maybe the video changed in database, refresh it 29 // Maybe the video changed in database, refresh it
31 const videoDatabase = await db.Video.loadByUUIDAndPopulateAccountAndServerAndTags(video.uuid) 30 const videoDatabase = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(video.uuid)
32 // Video does not exist anymore 31 // Video does not exist anymore
33 if (!videoDatabase) return undefined 32 if (!videoDatabase) return undefined
34 33