From 0c948c1659c0a6010f2bf58c402b1c9af192aa5e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 30 May 2018 10:49:40 +0200 Subject: Add ability to manually run transcoding job --- server/lib/job-queue/handlers/video-file.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'server/lib/job-queue') diff --git a/server/lib/job-queue/handlers/video-file.ts b/server/lib/job-queue/handlers/video-file.ts index 1b41d29e8..93f9e9fe7 100644 --- a/server/lib/job-queue/handlers/video-file.ts +++ b/server/lib/job-queue/handlers/video-file.ts @@ -11,7 +11,8 @@ import { JobQueue } from '../job-queue' export type VideoFilePayload = { videoUUID: string - resolution?: VideoResolution, + isNewVideo: boolean + resolution?: VideoResolution isPortraitMode?: boolean } @@ -32,7 +33,7 @@ async function processVideoFile (job: kue.Job) { await onVideoFileTranscoderSuccess(video) } else { await video.optimizeOriginalVideofile() - await onVideoFileOptimizerSuccess(video) + await onVideoFileOptimizerSuccess(video, payload.isNewVideo) } return video @@ -53,7 +54,7 @@ async function onVideoFileTranscoderSuccess (video: VideoModel) { return undefined } -async function onVideoFileOptimizerSuccess (video: VideoModel) { +async function onVideoFileOptimizerSuccess (video: VideoModel, isNewVideo: boolean) { if (video === undefined) return undefined // Maybe the video changed in database, refresh it @@ -62,11 +63,15 @@ async function onVideoFileOptimizerSuccess (video: VideoModel) { if (!videoDatabase) return undefined if (video.privacy !== VideoPrivacy.PRIVATE) { - // Now we'll add the video's meta data to our followers - await sequelizeTypescript.transaction(async t => { - await sendCreateVideo(video, t) - await shareVideoByServerAndChannel(video, t) - }) + if (isNewVideo === true) { + // Now we'll add the video's meta data to our followers + await sequelizeTypescript.transaction(async t => { + await sendCreateVideo(video, t) + await shareVideoByServerAndChannel(video, t) + }) + } else { + await sendUpdateVideo(video, undefined) + } } const { videoFileResolution } = await videoDatabase.getOriginalFileResolution() @@ -84,7 +89,8 @@ async function onVideoFileOptimizerSuccess (video: VideoModel) { for (const resolution of resolutionsEnabled) { const dataInput = { videoUUID: videoDatabase.uuid, - resolution + resolution, + isNewVideo } const p = JobQueue.Instance.createJob({ type: 'video-file', payload: dataInput }) -- cgit v1.2.3