X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fwebtorrent.ts;h=ce35b87dac395135d731a8875012d55f4f0c73b0;hb=7361c401b17415931f25f3a2137ba22a06a6a4ed;hp=924d630e761752e35e3a9408232ae6c58c9c1ca3;hpb=e37c85e933b320173c271fd1f6471679b759bc39;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts index 924d630e7..ce35b87da 100644 --- a/server/helpers/webtorrent.ts +++ b/server/helpers/webtorrent.ts @@ -5,7 +5,7 @@ import { createWriteStream, ensureDir, remove } from 'fs-extra' import { CONFIG } from '../initializers' import { dirname, join } from 'path' -async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName?: string }, timeout?: number) { +async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName?: string }, timeout: number) { const id = target.magnetUri || target.torrentName let timer @@ -50,12 +50,10 @@ async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName torrent.on('error', err => rej(err)) - if (timeout) { - timer = setTimeout(async () => { - return safeWebtorrentDestroy(webtorrent, torrentId, file ? { directoryPath, filepath: file.path } : undefined, target.torrentName) - .then(() => rej(new Error('Webtorrent download timeout.'))) - }, timeout) - } + timer = setTimeout(async () => { + return safeWebtorrentDestroy(webtorrent, torrentId, file ? { directoryPath, filepath: file.path } : undefined, target.torrentName) + .then(() => rej(new Error('Webtorrent download timeout.'))) + }, timeout) }) }