1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Safely remove webtorrent files

Only remove them on max quality HLS playlist generation
This commit is contained in:
Chocobozzz 2021-01-25 11:33:26 +01:00 committed by Chocobozzz
parent 77d7e851dc
commit 6939cbac48
4 changed files with 54 additions and 10 deletions

View file

@ -93,7 +93,7 @@ async function handleHLSJob (job: Bull.Job, payload: HLSTranscodingPayload, vide
job
})
await retryTransactionWrapper(onHlsPlaylistGeneration, video)
await retryTransactionWrapper(onHlsPlaylistGeneration, video, payload.resolution)
}
async function handleNewWebTorrentResolutionJob (
@ -121,11 +121,13 @@ async function handleWebTorrentOptimizeJob (job: Bull.Job, payload: OptimizeTran
// ---------------------------------------------------------------------------
async function onHlsPlaylistGeneration (video: MVideoFullLight) {
async function onHlsPlaylistGeneration (video: MVideoFullLight, resolution: number) {
if (video === undefined) return undefined
// We generated the HLS playlist, we don't need the webtorrent files anymore if the admin disabled it
if (CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) {
const maxQualityFile = video.getMaxQualityFile()
// We generated the max quality HLS playlist, we don't need the webtorrent files anymore if the admin disabled it
if (CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false && video.hasWebTorrentFiles() && maxQualityFile.resolution === resolution) {
for (const file of video.VideoFiles) {
await video.removeFile(file)
await file.destroy()