mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +02:00
Add timeout on youtube dl to cleaup files
This commit is contained in:
parent
2a27c451f7
commit
cf9166cf2f
5 changed files with 30 additions and 17 deletions
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue