+ return VideoPathManager.Instance.makeAvailableVideoFile(videoOrPlaylist, videoFile, async videoPath => {
+ const torrentContent = await createTorrentPromise(videoPath, options)
+
+ const torrentFilename = generateTorrentFileName(videoOrPlaylist, videoFile.resolution)
+ const torrentPath = join(CONFIG.STORAGE.TORRENTS_DIR, torrentFilename)
+ logger.info('Creating torrent %s.', torrentPath)
+
+ await writeFile(torrentPath, torrentContent)
+
+ // Remove old torrent file if it existed
+ if (videoFile.hasTorrent()) {
+ await remove(join(CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename))
+ }