aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/webtorrent.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/webtorrent.ts')
-rw-r--r--server/helpers/webtorrent.ts9
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'
2import { generateVideoTmpPath } from './utils' 2import { generateVideoTmpPath } from './utils'
3import * as WebTorrent from 'webtorrent' 3import * as WebTorrent from 'webtorrent'
4import { createWriteStream } from 'fs' 4import { createWriteStream } from 'fs'
5import { Instance as ParseTorrent } from 'parse-torrent'
6import { CONFIG } from '../initializers' 5import { CONFIG } from '../initializers'
7import { join } from 'path' 6import { 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 })