diff options
Diffstat (limited to 'server/helpers/webtorrent.ts')
-rw-r--r-- | server/helpers/webtorrent.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts index 04b3ac71b..121cd0b41 100644 --- a/server/helpers/webtorrent.ts +++ b/server/helpers/webtorrent.ts | |||
@@ -2,7 +2,6 @@ import { logger } from './logger' | |||
2 | import { generateVideoTmpPath } from './utils' | 2 | import { generateVideoTmpPath } from './utils' |
3 | import * as WebTorrent from 'webtorrent' | 3 | import * as WebTorrent from 'webtorrent' |
4 | import { createWriteStream } from 'fs' | 4 | import { createWriteStream } from 'fs' |
5 | import { Instance as ParseTorrent } from 'parse-torrent' | ||
6 | import { CONFIG } from '../initializers' | 5 | import { CONFIG } from '../initializers' |
7 | import { join } from 'path' | 6 | import { join } from 'path' |
8 | 7 | ||
@@ -20,10 +19,12 @@ function downloadWebTorrentVideo (target: { magnetUri: string, torrentName: stri | |||
20 | if (torrent.files.length !== 1) return rej(new Error('The number of files is not equal to 1 for ' + torrentId)) | 19 | if (torrent.files.length !== 1) return rej(new Error('The number of files is not equal to 1 for ' + torrentId)) |
21 | 20 | ||
22 | const file = torrent.files[ 0 ] | 21 | const file = torrent.files[ 0 ] |
23 | file.createReadStream().pipe(createWriteStream(path)) | ||
24 | }) | ||
25 | 22 | ||
26 | torrent.on('done', () => res(path)) | 23 | const writeStream = createWriteStream(path) |
24 | writeStream.on('finish', () => res(path)) | ||
25 | |||
26 | file.createReadStream().pipe(writeStream) | ||
27 | }) | ||
27 | 28 | ||
28 | torrent.on('error', err => rej(err)) | 29 | torrent.on('error', err => rej(err)) |
29 | }) | 30 | }) |