From 30ff39e7f07898ebb716c938123825c678b4e5af Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 15 Jul 2019 09:22:57 +0200 Subject: Move createTorrent in webtorrent utils --- server/helpers/core-utils.ts | 3 --- server/helpers/webtorrent.ts | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts index 64818d036..9771351e1 100644 --- a/server/helpers/core-utils.ts +++ b/server/helpers/core-utils.ts @@ -3,7 +3,6 @@ Useful to avoid circular dependencies. */ -import * as createTorrent from 'create-torrent' import { createHash, HexBase64Latin1Encoding, pseudoRandomBytes } from 'crypto' import { isAbsolute, join } from 'path' import * as pem from 'pem' @@ -257,7 +256,6 @@ function promisify2WithVoid (func: (arg1: T, arg2: U, cb: (err: any) => vo const pseudoRandomBytesPromise = promisify1(pseudoRandomBytes) const createPrivateKey = promisify1(pem.createPrivateKey) const getPublicKey = promisify1(pem.getPublicKey) -const createTorrentPromise = promisify2(createTorrent) const execPromise2 = promisify2(exec) const execPromise = promisify1(exec) @@ -288,7 +286,6 @@ export { pseudoRandomBytesPromise, createPrivateKey, getPublicKey, - createTorrentPromise, execPromise2, execPromise } diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts index 14dfe0d28..d2a22e8f0 100644 --- a/server/helpers/webtorrent.ts +++ b/server/helpers/webtorrent.ts @@ -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(createTorrent) + // --------------------------------------------------------------------------- export { + createTorrentPromise, downloadWebTorrentVideo } -- cgit v1.2.3