From cf9166cf2fb7b51a1137a259eed9338798c73500 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 1 Oct 2018 12:00:05 +0200 Subject: Add timeout on youtube dl to cleaup files --- server/helpers/webtorrent.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'server/helpers/webtorrent.ts') 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) }) } -- cgit v1.2.3