aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-03-19 15:02:36 +0100
committerChocobozzz <me@florianbigard.com>2018-03-19 15:22:18 +0100
commita797728009eb5c26cf55624a4a01e8ecb73f1297 (patch)
tree3dcfe4870986c9bacdfbd2a671143b5dfc4f47d3 /server/lib/job-queue/handlers
parent9d145133d82c11edfb2781871076b7063cc3ae3d (diff)
downloadPeerTube-a797728009eb5c26cf55624a4a01e8ecb73f1297.tar.gz
PeerTube-a797728009eb5c26cf55624a4a01e8ecb73f1297.tar.zst
PeerTube-a797728009eb5c26cf55624a4a01e8ecb73f1297.zip
Fix video_share_url duplicate key in transcoding job
Diffstat (limited to 'server/lib/job-queue/handlers')
-rw-r--r--server/lib/job-queue/handlers/video-file.ts40
1 files changed, 18 insertions, 22 deletions
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) {
63 63
64 if (video.privacy !== VideoPrivacy.PRIVATE) { 64 if (video.privacy !== VideoPrivacy.PRIVATE) {
65 // Now we'll add the video's meta data to our followers 65 // Now we'll add the video's meta data to our followers
66 await sendCreateVideo(video, undefined) 66 await sequelizeTypescript.transaction(async t => {
67 await shareVideoByServerAndChannel(video, undefined) 67 await sendCreateVideo(video, t)
68 await shareVideoByServerAndChannel(video, t)
69 })
68 } 70 }
69 71
70 const { videoFileResolution } = await videoDatabase.getOriginalFileResolution() 72 const { videoFileResolution } = await videoDatabase.getOriginalFileResolution()
@@ -77,27 +79,21 @@ async function onVideoFileOptimizerSuccess (video: VideoModel) {
77 ) 79 )
78 80
79 if (resolutionsEnabled.length !== 0) { 81 if (resolutionsEnabled.length !== 0) {
80 try { 82 const tasks: Promise<any>[] = []
81 await sequelizeTypescript.transaction(async t => { 83
82 const tasks: Promise<any>[] = [] 84 for (const resolution of resolutionsEnabled) {
83 85 const dataInput = {
84 for (const resolution of resolutionsEnabled) { 86 videoUUID: videoDatabase.uuid,
85 const dataInput = { 87 resolution
86 videoUUID: videoDatabase.uuid, 88 }
87 resolution 89
88 } 90 const p = JobQueue.Instance.createJob({ type: 'video-file', payload: dataInput })
89 91 tasks.push(p)
90 const p = JobQueue.Instance.createJob({ type: 'video-file', payload: dataInput })
91 tasks.push(p)
92 }
93
94 await Promise.all(tasks)
95 })
96
97 logger.info('Transcoding jobs created for uuid %s.', videoDatabase.uuid, { resolutionsEnabled })
98 } catch (err) {
99 logger.warn('Cannot transcode the video.', err)
100 } 92 }
93
94 await Promise.all(tasks)
95
96 logger.info('Transcoding jobs created for uuid %s.', videoDatabase.uuid, { resolutionsEnabled })
101 } else { 97 } else {
102 logger.info('No transcoding jobs created for video %s (no resolutions enabled).') 98 logger.info('No transcoding jobs created for video %s (no resolutions enabled).')
103 return undefined 99 return undefined