]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/job-queue/handlers/video-file-import.ts
Painfully debug concurrent import jobs
[github/Chocobozzz/PeerTube.git] / server / lib / job-queue / handlers / video-file-import.ts
index ae11f1de3c88dd20350a86c881d58cf1e7c9f7e0..cd95aa07561846511c4a292398fbc8fc1ef8c256 100644 (file)
@@ -1,15 +1,16 @@
 import * as Bull from 'bull'
-import { logger } from '../../../helpers/logger'
-import { VideoModel } from '../../../models/video/video'
-import { publishNewResolutionIfNeeded } from './video-transcoding'
-import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
 import { copy, stat } from 'fs-extra'
-import { VideoFileModel } from '../../../models/video/video-file'
 import { extname } from 'path'
-import { MVideoFile, MVideoWithFile } from '@server/typings/models'
 import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
 import { getVideoFilePath } from '@server/lib/video-paths'
+import { UserModel } from '@server/models/account/user'
+import { MVideoFile, MVideoWithFile } from '@server/types/models'
 import { VideoFileImportPayload } from '@shared/models'
+import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils'
+import { logger } from '../../../helpers/logger'
+import { VideoModel } from '../../../models/video/video'
+import { VideoFileModel } from '../../../models/video/video-file'
+import { onNewWebTorrentFileResolution } from './video-transcoding'
 
 async function processVideoFileImport (job: Bull.Job) {
   const payload = job.data as VideoFileImportPayload
@@ -22,9 +23,22 @@ async function processVideoFileImport (job: Bull.Job) {
     return undefined
   }
 
+  const data = await getVideoFileResolution(payload.filePath)
+
   await updateVideoFile(video, payload.filePath)
 
-  await publishNewResolutionIfNeeded(video)
+  const user = await UserModel.loadByChannelActorId(video.VideoChannel.actorId)
+
+  const newResolutionPayload = {
+    type: 'new-resolution-to-webtorrent' as 'new-resolution-to-webtorrent',
+    videoUUID: video.uuid,
+    resolution: data.videoFileResolution,
+    isPortraitMode: data.isPortraitMode,
+    copyCodecs: false,
+    isNewVideo: false
+  }
+  await onNewWebTorrentFileResolution(video, user, newResolutionPayload)
+
   return video
 }