aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-07-29 14:50:41 +0200
committerChocobozzz <me@florianbigard.com>2022-08-01 14:55:10 +0200
commit1bb4c9ab2e8b3b3022351b33a82a5e527fa5d4d7 (patch)
treea6554ee0a3ccc2ae402665b2ecf57bb38fd0ed72 /server/lib/job-queue
parent12d84abeca4917d2f1e3f308010bfcd56d37cb7c (diff)
downloadPeerTube-1bb4c9ab2e8b3b3022351b33a82a5e527fa5d4d7.tar.gz
PeerTube-1bb4c9ab2e8b3b3022351b33a82a5e527fa5d4d7.tar.zst
PeerTube-1bb4c9ab2e8b3b3022351b33a82a5e527fa5d4d7.zip
Add ability to delete a specific video file
Diffstat (limited to 'server/lib/job-queue')
-rw-r--r--server/lib/job-queue/handlers/video-file-import.ts2
-rw-r--r--server/lib/job-queue/handlers/video-studio-edition.ts18
-rw-r--r--server/lib/job-queue/handlers/video-transcoding.ts2
3 files changed, 8 insertions, 14 deletions
diff --git a/server/lib/job-queue/handlers/video-file-import.ts b/server/lib/job-queue/handlers/video-file-import.ts
index 1c600e2a7..71c5444af 100644
--- a/server/lib/job-queue/handlers/video-file-import.ts
+++ b/server/lib/job-queue/handlers/video-file-import.ts
@@ -55,7 +55,7 @@ async function updateVideoFile (video: MVideoFullLight, inputFilePath: string) {
55 55
56 if (currentVideoFile) { 56 if (currentVideoFile) {
57 // Remove old file and old torrent 57 // Remove old file and old torrent
58 await video.removeWebTorrentFileAndTorrent(currentVideoFile) 58 await video.removeWebTorrentFile(currentVideoFile)
59 // Remove the old video file from the array 59 // Remove the old video file from the array
60 video.VideoFiles = video.VideoFiles.filter(f => f !== currentVideoFile) 60 video.VideoFiles = video.VideoFiles.filter(f => f !== currentVideoFile)
61 61
diff --git a/server/lib/job-queue/handlers/video-studio-edition.ts b/server/lib/job-queue/handlers/video-studio-edition.ts
index 434d0ffe8..735150d57 100644
--- a/server/lib/job-queue/handlers/video-studio-edition.ts
+++ b/server/lib/job-queue/handlers/video-studio-edition.ts
@@ -9,6 +9,7 @@ import { generateWebTorrentVideoFilename } from '@server/lib/paths'
9import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/default-transcoding-profiles' 9import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/default-transcoding-profiles'
10import { isAbleToUploadVideo } from '@server/lib/user' 10import { isAbleToUploadVideo } from '@server/lib/user'
11import { addOptimizeOrMergeAudioJob } from '@server/lib/video' 11import { addOptimizeOrMergeAudioJob } from '@server/lib/video'
12import { removeHLSPlaylist, removeWebTorrentFile } from '@server/lib/video-file'
12import { VideoPathManager } from '@server/lib/video-path-manager' 13import { VideoPathManager } from '@server/lib/video-path-manager'
13import { approximateIntroOutroAdditionalSize } from '@server/lib/video-studio' 14import { approximateIntroOutroAdditionalSize } from '@server/lib/video-studio'
14import { UserModel } from '@server/models/user/user' 15import { UserModel } from '@server/models/user/user'
@@ -27,12 +28,12 @@ import {
27} from '@shared/extra-utils' 28} from '@shared/extra-utils'
28import { 29import {
29 VideoStudioEditionPayload, 30 VideoStudioEditionPayload,
30 VideoStudioTaskPayload, 31 VideoStudioTask,
31 VideoStudioTaskCutPayload, 32 VideoStudioTaskCutPayload,
32 VideoStudioTaskIntroPayload, 33 VideoStudioTaskIntroPayload,
33 VideoStudioTaskOutroPayload, 34 VideoStudioTaskOutroPayload,
34 VideoStudioTaskWatermarkPayload, 35 VideoStudioTaskPayload,
35 VideoStudioTask 36 VideoStudioTaskWatermarkPayload
36} from '@shared/models' 37} from '@shared/models'
37import { logger, loggerTagsFactory } from '../../../helpers/logger' 38import { logger, loggerTagsFactory } from '../../../helpers/logger'
38 39
@@ -89,7 +90,6 @@ async function processVideoStudioEdition (job: Job) {
89 await move(editionResultPath, outputPath) 90 await move(editionResultPath, outputPath)
90 91
91 await createTorrentAndSetInfoHashFromPath(video, newFile, outputPath) 92 await createTorrentAndSetInfoHashFromPath(video, newFile, outputPath)
92
93 await removeAllFiles(video, newFile) 93 await removeAllFiles(video, newFile)
94 94
95 await newFile.save() 95 await newFile.save()
@@ -197,18 +197,12 @@ async function buildNewFile (video: MVideoId, path: string) {
197} 197}
198 198
199async function removeAllFiles (video: MVideoWithAllFiles, webTorrentFileException: MVideoFile) { 199async function removeAllFiles (video: MVideoWithAllFiles, webTorrentFileException: MVideoFile) {
200 const hls = video.getHLSPlaylist() 200 await removeHLSPlaylist(video)
201
202 if (hls) {
203 await video.removeStreamingPlaylistFiles(hls)
204 await hls.destroy()
205 }
206 201
207 for (const file of video.VideoFiles) { 202 for (const file of video.VideoFiles) {
208 if (file.id === webTorrentFileException.id) continue 203 if (file.id === webTorrentFileException.id) continue
209 204
210 await video.removeWebTorrentFileAndTorrent(file) 205 await removeWebTorrentFile(video, file.id)
211 await file.destroy()
212 } 206 }
213} 207}
214 208
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts
index 5afca65ca..1b34ced14 100644
--- a/server/lib/job-queue/handlers/video-transcoding.ts
+++ b/server/lib/job-queue/handlers/video-transcoding.ts
@@ -149,7 +149,7 @@ async function onHlsPlaylistGeneration (video: MVideoFullLight, user: MUser, pay
149 if (payload.isMaxQuality && payload.autoDeleteWebTorrentIfNeeded && CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) { 149 if (payload.isMaxQuality && payload.autoDeleteWebTorrentIfNeeded && CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) {
150 // Remove webtorrent files if not enabled 150 // Remove webtorrent files if not enabled
151 for (const file of video.VideoFiles) { 151 for (const file of video.VideoFiles) {
152 await video.removeWebTorrentFileAndTorrent(file) 152 await video.removeWebTorrentFile(file)
153 await file.destroy() 153 await file.destroy()
154 } 154 }
155 155