Add debug messages to webtorrent tests

pull/4387/head
Chocobozzz 2021-09-02 09:53:27 +02:00
parent fbd2d42358
commit fbcd44d233
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 17 additions and 2 deletions

View File

@ -7,13 +7,28 @@ import { PeerTubeServer } from '../server'
let webtorrent: WebTorrent.Instance
function webtorrentAdd (torrent: string, refreshWebTorrent = false) {
function webtorrentAdd (torrentId: string, refreshWebTorrent = false) {
const WebTorrent = require('webtorrent')
if (!webtorrent) webtorrent = new WebTorrent()
if (refreshWebTorrent === true) webtorrent = new WebTorrent()
return new Promise<WebTorrent.Torrent>(res => webtorrent.add(torrent, res))
webtorrent.on('error', err => console.error('Error in webtorrent', err))
return new Promise<WebTorrent.Torrent>(res => {
const torrent = webtorrent.add(torrentId, res)
torrent.on('error', err => console.error('Error in webtorrent torrent', err))
torrent.on('warning', warn => {
const msg = typeof warn === 'string'
? warn
: warn.message
if (msg.includes('Unsupported')) return
console.error('Warning in webtorrent torrent', warn)
})
})
}
async function parseTorrentVideo (server: PeerTubeServer, file: VideoFile) {