]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/webtorrent.ts
Move createTorrent in webtorrent utils
[github/Chocobozzz/PeerTube.git] / server / helpers / webtorrent.ts
index 14dfe0d28c2bc89a182069b7c35a667841519fdb..d2a22e8f0e9b79ffbc75d3ae2ff3f27a6618a547 100644 (file)
@@ -4,6 +4,8 @@ import * as WebTorrent from 'webtorrent'
 import { createWriteStream, ensureDir, remove } from 'fs-extra'
 import { CONFIG } from '../initializers/config'
 import { dirname, join } from 'path'
+import * as createTorrent from 'create-torrent'
+import { promisify2 } from './core-utils'
 
 async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName?: string }, timeout: number) {
   const id = target.magnetUri || target.torrentName
@@ -57,9 +59,12 @@ async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName
   })
 }
 
+const createTorrentPromise = promisify2<string, any, any>(createTorrent)
+
 // ---------------------------------------------------------------------------
 
 export {
+  createTorrentPromise,
   downloadWebTorrentVideo
 }