diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-15 09:22:57 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-07-24 10:58:16 +0200 |
commit | 30ff39e7f07898ebb716c938123825c678b4e5af (patch) | |
tree | 338b55203ee757a0e5e3f2e449536b925c677556 | |
parent | b2195fafc292d6761c25fe51ca4e0328ab403424 (diff) | |
download | PeerTube-30ff39e7f07898ebb716c938123825c678b4e5af.tar.gz PeerTube-30ff39e7f07898ebb716c938123825c678b4e5af.tar.zst PeerTube-30ff39e7f07898ebb716c938123825c678b4e5af.zip |
Move createTorrent in webtorrent utils
-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 | ||||
-rw-r--r-- | shared/models/plugins/peertube-plugin.model.ts | 4 |
4 files changed, 10 insertions, 5 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 })[] = [ |
diff --git a/shared/models/plugins/peertube-plugin.model.ts b/shared/models/plugins/peertube-plugin.model.ts index e3c100027..2b0bb8cfa 100644 --- a/shared/models/plugins/peertube-plugin.model.ts +++ b/shared/models/plugins/peertube-plugin.model.ts | |||
@@ -1,6 +1,8 @@ | |||
1 | import { PluginType } from './plugin.type' | ||
2 | |||
1 | export interface PeerTubePlugin { | 3 | export interface PeerTubePlugin { |
2 | name: string | 4 | name: string |
3 | type: number | 5 | type: PluginType |
4 | latestVersion: string | 6 | latestVersion: string |
5 | version: string | 7 | version: string |
6 | enabled: boolean | 8 | enabled: boolean |