+ // Move physical file
+ const videoDir = CONFIG.STORAGE.VIDEOS_DIR
+ const destination = join(videoDir, video.getVideoFilename(videoFile))
+ await move(videoPhysicalFile.path, destination)
+ // This is important in case if there is another attempt in the retry process
+ videoPhysicalFile.filename = video.getVideoFilename(videoFile)
+ videoPhysicalFile.path = destination
+
+ // Process thumbnail or create it from the video
+ const thumbnailField = req.files['thumbnailfile']
+ const thumbnailModel = thumbnailField
+ ? await createVideoMiniatureFromExisting(thumbnailField[0].path, video, ThumbnailType.MINIATURE)
+ : await generateVideoMiniature(video, videoFile, ThumbnailType.MINIATURE)
+
+ // Process preview or create it from the video
+ const previewField = req.files['previewfile']
+ const previewModel = previewField
+ ? await createVideoMiniatureFromExisting(previewField[0].path, video, ThumbnailType.PREVIEW)
+ : await generateVideoMiniature(video, videoFile, ThumbnailType.PREVIEW)
+
+ // Create the torrent file
+ await video.createTorrentAndSetInfoHash(videoFile)
+
+ const { videoCreated, videoWasAutoBlacklisted } = await sequelizeTypescript.transaction(async t => {
+ const sequelizeOptions = { transaction: t }