diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-15 09:17:19 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-15 10:40:06 +0200 |
commit | eae0365b5c5468e51e9795b0e894815ebda86b4a (patch) | |
tree | 5da54b28c94d43d1715a0c69e35eb1cf3a1a959d /server/lib/job-queue | |
parent | 51f636ad0f928bb94069c9143e38df0518f6e4a7 (diff) | |
download | PeerTube-eae0365b5c5468e51e9795b0e894815ebda86b4a.tar.gz PeerTube-eae0365b5c5468e51e9795b0e894815ebda86b4a.tar.zst PeerTube-eae0365b5c5468e51e9795b0e894815ebda86b4a.zip |
Fix missing transactions
Diffstat (limited to 'server/lib/job-queue')
-rw-r--r-- | server/lib/job-queue/handlers/video-transcoding.ts | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts index 8d659daa6..8f218ca3a 100644 --- a/server/lib/job-queue/handlers/video-transcoding.ts +++ b/server/lib/job-queue/handlers/video-transcoding.ts | |||
@@ -151,35 +151,31 @@ async function onVideoFileOptimizer ( | |||
151 | // Outside the transaction (IO on disk) | 151 | // Outside the transaction (IO on disk) |
152 | const { videoFileResolution, isPortraitMode } = await videoArg.getMaxQualityResolution() | 152 | const { videoFileResolution, isPortraitMode } = await videoArg.getMaxQualityResolution() |
153 | 153 | ||
154 | const { videoDatabase, videoPublished } = await sequelizeTypescript.transaction(async t => { | 154 | // Maybe the video changed in database, refresh it |
155 | // Maybe the video changed in database, refresh it | 155 | const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoArg.uuid) |
156 | const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoArg.uuid, t) | 156 | // Video does not exist anymore |
157 | // Video does not exist anymore | 157 | if (!videoDatabase) return undefined |
158 | if (!videoDatabase) return undefined | 158 | |
159 | 159 | let videoPublished = false | |
160 | let videoPublished = false | 160 | |
161 | 161 | // Generate HLS version of the original file | |
162 | // Generate HLS version of the original file | 162 | const originalFileHLSPayload = Object.assign({}, payload, { |
163 | const originalFileHLSPayload = Object.assign({}, payload, { | 163 | isPortraitMode, |
164 | isPortraitMode, | 164 | resolution: videoDatabase.getMaxQualityFile().resolution, |
165 | resolution: videoDatabase.getMaxQualityFile().resolution, | 165 | // If we quick transcoded original file, force transcoding for HLS to avoid some weird playback issues |
166 | // If we quick transcoded original file, force transcoding for HLS to avoid some weird playback issues | 166 | copyCodecs: transcodeType !== 'quick-transcode', |
167 | copyCodecs: transcodeType !== 'quick-transcode', | 167 | isMaxQuality: true |
168 | isMaxQuality: true | 168 | }) |
169 | }) | 169 | const hasHls = await createHlsJobIfEnabled(user, originalFileHLSPayload) |
170 | const hasHls = await createHlsJobIfEnabled(user, originalFileHLSPayload) | ||
171 | |||
172 | const hasNewResolutions = await createLowerResolutionsJobs(videoDatabase, user, videoFileResolution, isPortraitMode, 'webtorrent') | ||
173 | |||
174 | if (!hasHls && !hasNewResolutions) { | ||
175 | // No transcoding to do, it's now published | ||
176 | videoPublished = await videoDatabase.publishIfNeededAndSave(t) | ||
177 | } | ||
178 | 170 | ||
179 | await federateVideoIfNeeded(videoDatabase, payload.isNewVideo, t) | 171 | const hasNewResolutions = await createLowerResolutionsJobs(videoDatabase, user, videoFileResolution, isPortraitMode, 'webtorrent') |
180 | 172 | ||
181 | return { videoDatabase, videoPublished } | 173 | if (!hasHls && !hasNewResolutions) { |
182 | }) | 174 | // No transcoding to do, it's now published |
175 | videoPublished = await videoDatabase.publishIfNeededAndSave(undefined) | ||
176 | } | ||
177 | |||
178 | await federateVideoIfNeeded(videoDatabase, payload.isNewVideo) | ||
183 | 179 | ||
184 | if (payload.isNewVideo) Notifier.Instance.notifyOnNewVideoIfNeeded(videoDatabase) | 180 | if (payload.isNewVideo) Notifier.Instance.notifyOnNewVideoIfNeeded(videoDatabase) |
185 | if (videoPublished) Notifier.Instance.notifyOnVideoPublishedAfterTranscoding(videoDatabase) | 181 | if (videoPublished) Notifier.Instance.notifyOnVideoPublishedAfterTranscoding(videoDatabase) |