]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/job-queue/handlers/video-transcoding.ts
Suffix external auth username on conflict
[github/Chocobozzz/PeerTube.git] / server / lib / job-queue / handlers / video-transcoding.ts
index 512979734f6e6adc1b9f08442d6c99f4d79d402c..d3fb7778b76487e214e216fa2445644260ebfd50 100644 (file)
@@ -26,6 +26,7 @@ import {
   optimizeOriginalVideofile,
   transcodeNewWebTorrentResolution
 } from '../../transcoding/transcoding'
+import { Hooks } from '@server/lib/plugins/hooks'
 
 type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void>
 
@@ -42,7 +43,7 @@ async function processVideoTranscoding (job: Job) {
   const payload = job.data as VideoTranscodingPayload
   logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID))
 
-  const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID)
+  const video = await VideoModel.loadFull(payload.videoUUID)
   // No video, maybe deleted?
   if (!video) {
     logger.info('Do not process job %d, video does not exist.', job.id, lTags(payload.videoUUID))
@@ -149,7 +150,7 @@ async function onHlsPlaylistGeneration (video: MVideoFullLight, user: MUser, pay
   if (payload.isMaxQuality && payload.autoDeleteWebTorrentIfNeeded && CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) {
     // Remove webtorrent files if not enabled
     for (const file of video.VideoFiles) {
-      await video.removeWebTorrentFileAndTorrent(file)
+      await video.removeWebTorrentFile(file)
       await file.destroy()
     }
 
@@ -168,7 +169,7 @@ async function onHlsPlaylistGeneration (video: MVideoFullLight, user: MUser, pay
   }
 
   await VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode')
-  await retryTransactionWrapper(moveToNextState, video, payload.isNewVideo)
+  await retryTransactionWrapper(moveToNextState, { video, isNewVideo: payload.isNewVideo })
 }
 
 async function onVideoFirstWebTorrentTranscoding (
@@ -180,7 +181,7 @@ async function onVideoFirstWebTorrentTranscoding (
   const { resolution, isPortraitMode, audioStream } = await videoArg.probeMaxQualityFile()
 
   // Maybe the video changed in database, refresh it
-  const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoArg.uuid)
+  const videoDatabase = await VideoModel.loadFull(videoArg.uuid)
   // Video does not exist anymore
   if (!videoDatabase) return undefined
 
@@ -210,7 +211,7 @@ async function onVideoFirstWebTorrentTranscoding (
 
   // Move to next state if there are no other resolutions to generate
   if (!hasHls && !hasNewResolutions) {
-    await retryTransactionWrapper(moveToNextState, videoDatabase, payload.isNewVideo)
+    await retryTransactionWrapper(moveToNextState, { video: videoDatabase, isNewVideo: payload.isNewVideo })
   }
 }
 
@@ -225,7 +226,7 @@ async function onNewWebTorrentFileResolution (
 
   await VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode')
 
-  await retryTransactionWrapper(moveToNextState, video, payload.isNewVideo)
+  await retryTransactionWrapper(moveToNextState, { video, isNewVideo: payload.isNewVideo })
 }
 
 // ---------------------------------------------------------------------------
@@ -269,7 +270,12 @@ async function createLowerResolutionsJobs (options: {
   const { video, user, videoFileResolution, isPortraitMode, isNewVideo, hasAudio, type } = options
 
   // Create transcoding jobs if there are enabled resolutions
-  const resolutionsEnabled = computeLowerResolutionsToTranscode(videoFileResolution, 'vod')
+  const resolutionsEnabled = await Hooks.wrapObject(
+    computeLowerResolutionsToTranscode(videoFileResolution, 'vod'),
+    'filter:transcoding.auto.lower-resolutions-to-transcode.result',
+    options
+  )
+
   const resolutionCreated: string[] = []
 
   for (const resolution of resolutionsEnabled) {