diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-12 17:53:50 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-13 16:50:33 +0100 |
commit | 3fd3ab2d34d512b160a5e6084d7609be7b4f4452 (patch) | |
tree | e5ca358287fca6ecacce83defcf23af1e8e9f419 /server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts | |
parent | c893d4514e6ecbf282c7985fe5f82b8acd8a1137 (diff) | |
download | PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.gz PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.zst PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.zip |
Move models to typescript-sequelize
Diffstat (limited to 'server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts')
-rw-r--r-- | server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts | 16 |
1 files changed, 8 insertions, 8 deletions
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 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import * as Bluebird from 'bluebird' |
2 | import { computeResolutionsToTranscode, logger } from '../../../helpers' | 2 | import { computeResolutionsToTranscode, logger } from '../../../helpers' |
3 | import { database as db } from '../../../initializers/database' | 3 | import { sequelizeTypescript } from '../../../initializers' |
4 | import { VideoInstance } from '../../../models' | 4 | import { VideoModel } from '../../../models/video/video' |
5 | import { sendAddVideo } from '../../activitypub/send/send-add' | 5 | import { shareVideoByServer } from '../../activitypub' |
6 | import { sendAddVideo } from '../../activitypub/send' | ||
6 | import { JobScheduler } from '../job-scheduler' | 7 | import { JobScheduler } from '../job-scheduler' |
7 | import { TranscodingJobPayload } from './transcoding-job-scheduler' | 8 | import { TranscodingJobPayload } from './transcoding-job-scheduler' |
8 | import { shareVideoByServer } from '../../activitypub/share' | ||
9 | 9 | ||
10 | async function process (data: TranscodingJobPayload, jobId: number) { | 10 | async 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 | ||
28 | async function onSuccess (jobId: number, video: VideoInstance, jobScheduler: JobScheduler<TranscodingJobPayload, VideoInstance>) { | 28 | async 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) { |