diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/helpers/core-utils.ts | 3 | ||||
-rw-r--r-- | server/helpers/webtorrent.ts | 5 | ||||
-rw-r--r-- | server/models/video/video.ts | 3 |
3 files changed, 7 insertions, 4 deletions
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 @@ | |||
3 | Useful to avoid circular dependencies. | 3 | Useful to avoid circular dependencies. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | import * as createTorrent from 'create-torrent' | ||
7 | import { createHash, HexBase64Latin1Encoding, pseudoRandomBytes } from 'crypto' | 6 | import { createHash, HexBase64Latin1Encoding, pseudoRandomBytes } from 'crypto' |
8 | import { isAbsolute, join } from 'path' | 7 | import { isAbsolute, join } from 'path' |
9 | import * as pem from 'pem' | 8 | import * as pem from 'pem' |
@@ -257,7 +256,6 @@ function promisify2WithVoid<T, U> (func: (arg1: T, arg2: U, cb: (err: any) => vo | |||
257 | const pseudoRandomBytesPromise = promisify1<number, Buffer>(pseudoRandomBytes) | 256 | const pseudoRandomBytesPromise = promisify1<number, Buffer>(pseudoRandomBytes) |
258 | const createPrivateKey = promisify1<number, { key: string }>(pem.createPrivateKey) | 257 | const createPrivateKey = promisify1<number, { key: string }>(pem.createPrivateKey) |
259 | const getPublicKey = promisify1<string, { publicKey: string }>(pem.getPublicKey) | 258 | const getPublicKey = promisify1<string, { publicKey: string }>(pem.getPublicKey) |
260 | const createTorrentPromise = promisify2<string, any, any>(createTorrent) | ||
261 | const execPromise2 = promisify2<string, any, string>(exec) | 259 | const execPromise2 = promisify2<string, any, string>(exec) |
262 | const execPromise = promisify1<string, string>(exec) | 260 | const execPromise = promisify1<string, string>(exec) |
263 | 261 | ||
@@ -288,7 +286,6 @@ export { | |||
288 | pseudoRandomBytesPromise, | 286 | pseudoRandomBytesPromise, |
289 | createPrivateKey, | 287 | createPrivateKey, |
290 | getPublicKey, | 288 | getPublicKey, |
291 | createTorrentPromise, | ||
292 | execPromise2, | 289 | execPromise2, |
293 | execPromise | 290 | execPromise |
294 | } | 291 | } |
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' | |||
4 | import { createWriteStream, ensureDir, remove } from 'fs-extra' | 4 | import { createWriteStream, ensureDir, remove } from 'fs-extra' |
5 | import { CONFIG } from '../initializers/config' | 5 | import { CONFIG } from '../initializers/config' |
6 | import { dirname, join } from 'path' | 6 | import { dirname, join } from 'path' |
7 | import * as createTorrent from 'create-torrent' | ||
8 | import { promisify2 } from './core-utils' | ||
7 | 9 | ||
8 | async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName?: string }, timeout: number) { | 10 | async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName?: string }, timeout: number) { |
9 | const id = target.magnetUri || target.torrentName | 11 | const id = target.magnetUri || target.torrentName |
@@ -57,9 +59,12 @@ async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName | |||
57 | }) | 59 | }) |
58 | } | 60 | } |
59 | 61 | ||
62 | const createTorrentPromise = promisify2<string, any, any>(createTorrent) | ||
63 | |||
60 | // --------------------------------------------------------------------------- | 64 | // --------------------------------------------------------------------------- |
61 | 65 | ||
62 | export { | 66 | export { |
67 | createTorrentPromise, | ||
63 | downloadWebTorrentVideo | 68 | downloadWebTorrentVideo |
64 | } | 69 | } |
65 | 70 | ||
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 92d07b5bc..ec3d5ddb0 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -40,7 +40,7 @@ import { UserRight, VideoPrivacy, VideoState } from '../../../shared' | |||
40 | import { VideoTorrentObject } from '../../../shared/models/activitypub/objects' | 40 | import { VideoTorrentObject } from '../../../shared/models/activitypub/objects' |
41 | import { Video, VideoDetails, VideoFile } from '../../../shared/models/videos' | 41 | import { Video, VideoDetails, VideoFile } from '../../../shared/models/videos' |
42 | import { VideoFilter } from '../../../shared/models/videos/video-query.type' | 42 | import { VideoFilter } from '../../../shared/models/videos/video-query.type' |
43 | import { createTorrentPromise, peertubeTruncate } from '../../helpers/core-utils' | 43 | import { peertubeTruncate } from '../../helpers/core-utils' |
44 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 44 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
45 | import { isArray, isBooleanValid } from '../../helpers/custom-validators/misc' | 45 | import { isArray, isBooleanValid } from '../../helpers/custom-validators/misc' |
46 | import { | 46 | import { |
@@ -117,6 +117,7 @@ import { VideoPlaylistElementModel } from './video-playlist-element' | |||
117 | import { CONFIG } from '../../initializers/config' | 117 | import { CONFIG } from '../../initializers/config' |
118 | import { ThumbnailModel } from './thumbnail' | 118 | import { ThumbnailModel } from './thumbnail' |
119 | import { ThumbnailType } from '../../../shared/models/videos/thumbnail.type' | 119 | import { ThumbnailType } from '../../../shared/models/videos/thumbnail.type' |
120 | import { createTorrentPromise } from '../../helpers/webtorrent' | ||
120 | 121 | ||
121 | // FIXME: Define indexes here because there is an issue with TS and Sequelize.literal when called directly in the annotation | 122 | // FIXME: Define indexes here because there is an issue with TS and Sequelize.literal when called directly in the annotation |
122 | const indexes: (ModelIndexesOptions & { where?: WhereOptions })[] = [ | 123 | const indexes: (ModelIndexesOptions & { where?: WhereOptions })[] = [ |