]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/job-queue/handlers/video-file-import.ts
Remove deprecated transcoding job names
[github/Chocobozzz/PeerTube.git] / server / lib / job-queue / handlers / video-file-import.ts
index 8297a15716819c5fba66efeb3ef7d2be5f0f8f17..4d199f24739bad97cf328020517fc8713edb2f9e 100644 (file)
@@ -1,8 +1,8 @@
 import * as Bull from 'bull'
 import { copy, stat } from 'fs-extra'
-import { extname } from 'path'
+import { getLowercaseExtension } from '@server/helpers/core-utils'
 import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
-import { generateVideoFilename, getVideoFilePath } from '@server/lib/video-paths'
+import { generateWebTorrentVideoFilename, getVideoFilePath } from '@server/lib/video-paths'
 import { UserModel } from '@server/models/user/user'
 import { MVideoFullLight } from '@server/types/models'
 import { VideoFileImportPayload } from '@shared/models'
@@ -55,14 +55,13 @@ async function updateVideoFile (video: MVideoFullLight, inputFilePath: string) {
   const { size } = await stat(inputFilePath)
   const fps = await getVideoFileFPS(inputFilePath)
 
-  const fileExt = extname(inputFilePath)
+  const fileExt = getLowercaseExtension(inputFilePath)
 
   const currentVideoFile = video.VideoFiles.find(videoFile => videoFile.resolution === videoFileResolution)
 
   if (currentVideoFile) {
     // Remove old file and old torrent
-    await video.removeFile(currentVideoFile)
-    await currentVideoFile.removeTorrent()
+    await video.removeFileAndTorrent(currentVideoFile)
     // Remove the old video file from the array
     video.VideoFiles = video.VideoFiles.filter(f => f !== currentVideoFile)
 
@@ -72,7 +71,7 @@ async function updateVideoFile (video: MVideoFullLight, inputFilePath: string) {
   const newVideoFile = new VideoFileModel({
     resolution: videoFileResolution,
     extname: fileExt,
-    filename: generateVideoFilename(video, false, videoFileResolution, fileExt),
+    filename: generateWebTorrentVideoFilename(videoFileResolution, fileExt),
     size,
     fps,
     videoId: video.id