]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/job-queue/handlers/video-transcoding.ts
Correctly remove torrents with HLS only
[github/Chocobozzz/PeerTube.git] / server / lib / job-queue / handlers / video-transcoding.ts
index ee241ad03e65b747786f94f1ac4c8ddb5df042c7..8f88f0a8a84ad5a33fd308b1e5c3951903b4d524 100644 (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,13 +121,16 @@ 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 video.removeTorrent(file)
       await file.destroy()
     }