job
})
- await retryTransactionWrapper(onHlsPlaylistGeneration, video)
+ await retryTransactionWrapper(onHlsPlaylistGeneration, video, payload.resolution)
}
async function handleNewWebTorrentResolutionJob (
// ---------------------------------------------------------------------------
-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()
}