From a797728009eb5c26cf55624a4a01e8ecb73f1297 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 19 Mar 2018 15:02:36 +0100 Subject: Fix video_share_url duplicate key in transcoding job --- server/lib/job-queue/handlers/video-file.ts | 40 +++++++++++++---------------- 1 file changed, 18 insertions(+), 22 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 bd9412290..1b41d29e8 100644 --- a/server/lib/job-queue/handlers/video-file.ts +++ b/server/lib/job-queue/handlers/video-file.ts @@ -63,8 +63,10 @@ async function onVideoFileOptimizerSuccess (video: VideoModel) { if (video.privacy !== VideoPrivacy.PRIVATE) { // Now we'll add the video's meta data to our followers - await sendCreateVideo(video, undefined) - await shareVideoByServerAndChannel(video, undefined) + await sequelizeTypescript.transaction(async t => { + await sendCreateVideo(video, t) + await shareVideoByServerAndChannel(video, t) + }) } const { videoFileResolution } = await videoDatabase.getOriginalFileResolution() @@ -77,27 +79,21 @@ async function onVideoFileOptimizerSuccess (video: VideoModel) { ) if (resolutionsEnabled.length !== 0) { - try { - await sequelizeTypescript.transaction(async t => { - const tasks: Promise[] = [] - - for (const resolution of resolutionsEnabled) { - const dataInput = { - videoUUID: videoDatabase.uuid, - resolution - } - - const p = JobQueue.Instance.createJob({ type: 'video-file', payload: dataInput }) - tasks.push(p) - } - - await Promise.all(tasks) - }) - - logger.info('Transcoding jobs created for uuid %s.', videoDatabase.uuid, { resolutionsEnabled }) - } catch (err) { - logger.warn('Cannot transcode the video.', err) + const tasks: Promise[] = [] + + for (const resolution of resolutionsEnabled) { + const dataInput = { + videoUUID: videoDatabase.uuid, + resolution + } + + const p = JobQueue.Instance.createJob({ type: 'video-file', payload: dataInput }) + tasks.push(p) } + + await Promise.all(tasks) + + logger.info('Transcoding jobs created for uuid %s.', videoDatabase.uuid, { resolutionsEnabled }) } else { logger.info('No transcoding jobs created for video %s (no resolutions enabled).') return undefined -- cgit v1.2.3