diff options
author | Chocobozzz <me@florianbigard.com> | 2021-01-25 11:33:26 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-01-25 14:38:52 +0100 |
commit | 6939cbac48e0a9823b34577836480ae3c28186be (patch) | |
tree | 9ee44d4d26931ee0550121acd4f19e83b4c5caf3 /server/lib/job-queue/handlers | |
parent | 77d7e851dccf17dcc89e8fcc2db3f655d1e63f95 (diff) | |
download | PeerTube-6939cbac48e0a9823b34577836480ae3c28186be.tar.gz PeerTube-6939cbac48e0a9823b34577836480ae3c28186be.tar.zst PeerTube-6939cbac48e0a9823b34577836480ae3c28186be.zip |
Safely remove webtorrent files
Only remove them on max quality HLS playlist generation
Diffstat (limited to 'server/lib/job-queue/handlers')
-rw-r--r-- | server/lib/job-queue/handlers/video-transcoding.ts | 10 |
1 files changed, 6 insertions, 4 deletions
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 | |||
93 | job | 93 | job |
94 | }) | 94 | }) |
95 | 95 | ||
96 | await retryTransactionWrapper(onHlsPlaylistGeneration, video) | 96 | await retryTransactionWrapper(onHlsPlaylistGeneration, video, payload.resolution) |
97 | } | 97 | } |
98 | 98 | ||
99 | async function handleNewWebTorrentResolutionJob ( | 99 | async function handleNewWebTorrentResolutionJob ( |
@@ -121,11 +121,13 @@ async function handleWebTorrentOptimizeJob (job: Bull.Job, payload: OptimizeTran | |||
121 | 121 | ||
122 | // --------------------------------------------------------------------------- | 122 | // --------------------------------------------------------------------------- |
123 | 123 | ||
124 | async function onHlsPlaylistGeneration (video: MVideoFullLight) { | 124 | async function onHlsPlaylistGeneration (video: MVideoFullLight, resolution: number) { |
125 | if (video === undefined) return undefined | 125 | if (video === undefined) return undefined |
126 | 126 | ||
127 | // We generated the HLS playlist, we don't need the webtorrent files anymore if the admin disabled it | 127 | const maxQualityFile = video.getMaxQualityFile() |
128 | if (CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) { | 128 | |
129 | // We generated the max quality HLS playlist, we don't need the webtorrent files anymore if the admin disabled it | ||
130 | if (CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false && video.hasWebTorrentFiles() && maxQualityFile.resolution === resolution) { | ||
129 | for (const file of video.VideoFiles) { | 131 | for (const file of video.VideoFiles) { |
130 | await video.removeFile(file) | 132 | await video.removeFile(file) |
131 | await file.destroy() | 133 | await file.destroy() |