aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-09-02 09:53:27 +0200
committerChocobozzz <me@florianbigard.com>2021-09-02 09:55:48 +0200
commitfbcd44d2333bdd093334a90fd99f6d99bfd72744 (patch)
tree9b417ac58a40175063e130b78ad9ebe9a94bd6b7 /shared
parentfbd2d423587caace6ff3e98840a8d4d4e4938266 (diff)
downloadPeerTube-fbcd44d2333bdd093334a90fd99f6d99bfd72744.tar.gz
PeerTube-fbcd44d2333bdd093334a90fd99f6d99bfd72744.tar.zst
PeerTube-fbcd44d2333bdd093334a90fd99f6d99bfd72744.zip
Add debug messages to webtorrent tests
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/miscs/webtorrent.ts19
1 files changed, 17 insertions, 2 deletions
diff --git a/shared/extra-utils/miscs/webtorrent.ts b/shared/extra-utils/miscs/webtorrent.ts
index 8fe2ad821..b610fdda8 100644
--- a/shared/extra-utils/miscs/webtorrent.ts
+++ b/shared/extra-utils/miscs/webtorrent.ts
@@ -7,13 +7,28 @@ import { PeerTubeServer } from '../server'
7 7
8let webtorrent: WebTorrent.Instance 8let webtorrent: WebTorrent.Instance
9 9
10function webtorrentAdd (torrent: string, refreshWebTorrent = false) { 10function webtorrentAdd (torrentId: string, refreshWebTorrent = false) {
11 const WebTorrent = require('webtorrent') 11 const WebTorrent = require('webtorrent')
12 12
13 if (!webtorrent) webtorrent = new WebTorrent() 13 if (!webtorrent) webtorrent = new WebTorrent()
14 if (refreshWebTorrent === true) webtorrent = new WebTorrent() 14 if (refreshWebTorrent === true) webtorrent = new WebTorrent()
15 15
16 return new Promise<WebTorrent.Torrent>(res => webtorrent.add(torrent, res)) 16 webtorrent.on('error', err => console.error('Error in webtorrent', err))
17
18 return new Promise<WebTorrent.Torrent>(res => {
19 const torrent = webtorrent.add(torrentId, res)
20
21 torrent.on('error', err => console.error('Error in webtorrent torrent', err))
22 torrent.on('warning', warn => {
23 const msg = typeof warn === 'string'
24 ? warn
25 : warn.message
26
27 if (msg.includes('Unsupported')) return
28
29 console.error('Warning in webtorrent torrent', warn)
30 })
31 })
17} 32}
18 33
19async function parseTorrentVideo (server: PeerTubeServer, file: VideoFile) { 34async function parseTorrentVideo (server: PeerTubeServer, file: VideoFile) {