From 6939cbac48e0a9823b34577836480ae3c28186be Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 25 Jan 2021 11:33:26 +0100 Subject: Safely remove webtorrent files Only remove them on max quality HLS playlist generation --- server/lib/job-queue/handlers/video-transcoding.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'server/lib/job-queue/handlers/video-transcoding.ts') diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts index ee241ad03..9c0b1d1f1 100644 --- a/server/lib/job-queue/handlers/video-transcoding.ts +++ b/server/lib/job-queue/handlers/video-transcoding.ts @@ -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() -- cgit v1.2.3