]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/job-queue/handlers/video-studio-edition.ts
Suffix external auth username on conflict
[github/Chocobozzz/PeerTube.git] / server / lib / job-queue / handlers / video-studio-edition.ts
index cf3064a7ace5e5c8e34e2611dccbf07edb554214..735150d57fecd0b26b13b95233882e2886f52a3f 100644 (file)
@@ -9,6 +9,7 @@ import { generateWebTorrentVideoFilename } from '@server/lib/paths'
 import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/default-transcoding-profiles'
 import { isAbleToUploadVideo } from '@server/lib/user'
 import { addOptimizeOrMergeAudioJob } from '@server/lib/video'
+import { removeHLSPlaylist, removeWebTorrentFile } from '@server/lib/video-file'
 import { VideoPathManager } from '@server/lib/video-path-manager'
 import { approximateIntroOutroAdditionalSize } from '@server/lib/video-studio'
 import { UserModel } from '@server/models/user/user'
@@ -27,12 +28,12 @@ import {
 } from '@shared/extra-utils'
 import {
   VideoStudioEditionPayload,
-  VideoStudioTaskPayload,
+  VideoStudioTask,
   VideoStudioTaskCutPayload,
   VideoStudioTaskIntroPayload,
   VideoStudioTaskOutroPayload,
-  VideoStudioTaskWatermarkPayload,
-  VideoStudioTask
+  VideoStudioTaskPayload,
+  VideoStudioTaskWatermarkPayload
 } from '@shared/models'
 import { logger, loggerTagsFactory } from '../../../helpers/logger'
 
@@ -44,7 +45,7 @@ async function processVideoStudioEdition (job: Job) {
 
   logger.info('Process video studio edition of %s in job %d.', payload.videoUUID, job.id, lTags)
 
-  const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID)
+  const video = await VideoModel.loadFull(payload.videoUUID)
 
   // No video, maybe deleted?
   if (!video) {
@@ -89,7 +90,6 @@ async function processVideoStudioEdition (job: Job) {
   await move(editionResultPath, outputPath)
 
   await createTorrentAndSetInfoHashFromPath(video, newFile, outputPath)
-
   await removeAllFiles(video, newFile)
 
   await newFile.save()
@@ -197,18 +197,12 @@ async function buildNewFile (video: MVideoId, path: string) {
 }
 
 async function removeAllFiles (video: MVideoWithAllFiles, webTorrentFileException: MVideoFile) {
-  const hls = video.getHLSPlaylist()
-
-  if (hls) {
-    await video.removeStreamingPlaylistFiles(hls)
-    await hls.destroy()
-  }
+  await removeHLSPlaylist(video)
 
   for (const file of video.VideoFiles) {
     if (file.id === webTorrentFileException.id) continue
 
-    await video.removeWebTorrentFileAndTorrent(file)
-    await file.destroy()
+    await removeWebTorrentFile(video, file.id)
   }
 }