-function createTorrentFederate (video: MVideoFullLight, videoFile: MVideoFile) {
- // Create the torrent file in async way because it could be long
- return createTorrentAndSetInfoHashAsync(video, videoFile)
- .catch(err => logger.error('Cannot create torrent file for video %s', video.url, { err, ...lTags(video.uuid) }))
- .then(() => VideoModel.loadAndPopulateAccountAndServerAndTags(video.id))
- .then(refreshedVideo => {
- if (!refreshedVideo) return
+ video.state === VideoState.TO_TRANSCODE
+ ? await buildOptimizeOrMergeAudioJob({ video, videoFile, user })
+ : undefined
+ )
+}