+ // Create the torrent file in async way because it could be long
+ createTorrentAndSetInfoHashAsync(video, videoFile)
+ .catch(err => logger.error('Cannot create torrent file for video %s', video.url, { err }))
+ .then(() => VideoModel.loadAndPopulateAccountAndServerAndTags(video.id))
+ .then(refreshedVideo => {
+ if (!refreshedVideo) return
+
+ // Only federate and notify after the torrent creation
+ Notifier.Instance.notifyOnNewVideoIfNeeded(refreshedVideo)
+
+ return retryTransactionWrapper(() => {
+ return sequelizeTypescript.transaction(t => federateVideoIfNeeded(refreshedVideo, true, t))
+ })
+ })
+ .catch(err => logger.error('Cannot federate or notify video creation %s', video.url, { err }))