From 0bae66632a8767f3d5aca080af314bcab56e1889 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 26 Aug 2021 15:19:11 +0200 Subject: More logs for webtorrent download --- server/helpers/webtorrent.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'server/helpers') diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts index becad533e..5fe4c1165 100644 --- a/server/helpers/webtorrent.ts +++ b/server/helpers/webtorrent.ts @@ -17,6 +17,7 @@ import { promisify2 } from './core-utils' import { logger } from './logger' import { generateVideoImportTmpPath } from './utils' import { extractVideo } from './video' +import { pipeline } from 'stream' const createTorrentPromise = promisify2(createTorrent) @@ -49,6 +50,8 @@ async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName .then(() => rej(new Error('Cannot import torrent ' + torrentId + ': there are multiple files in it'))) } + logger.debug('Got torrent from webtorrent %s.', id, { infoHash: torrent.infoHash, files: torrent.files }) + file = torrent.files[0] // FIXME: avoid creating another stream when https://github.com/webtorrent/webtorrent/issues/1517 is fixed @@ -61,7 +64,11 @@ async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName .catch(err => logger.error('Cannot destroy webtorrent.', { err })) }) - file.createReadStream().pipe(writeStream) + pipeline( + file.createReadStream(), + writeStream, + err => rej(err) + ) }) torrent.on('error', err => rej(err)) -- cgit v1.2.3