From 1bb4c9ab2e8b3b3022351b33a82a5e527fa5d4d7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 29 Jul 2022 14:50:41 +0200 Subject: Add ability to delete a specific video file --- server/lib/job-queue/handlers/video-file-import.ts | 2 +- server/lib/job-queue/handlers/video-studio-edition.ts | 18 ++++++------------ server/lib/job-queue/handlers/video-transcoding.ts | 2 +- 3 files changed, 8 insertions(+), 14 deletions(-) (limited to 'server/lib/job-queue/handlers') 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) { if (currentVideoFile) { // Remove old file and old torrent - await video.removeWebTorrentFileAndTorrent(currentVideoFile) + await video.removeWebTorrentFile(currentVideoFile) // Remove the old video file from the array video.VideoFiles = video.VideoFiles.filter(f => f !== currentVideoFile) 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' import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/default-transcoding-profiles' import { isAbleToUploadVideo } from '@server/lib/user' import { addOptimizeOrMergeAudioJob } from '@server/lib/video' +import { removeHLSPlaylist, removeWebTorrentFile } from '@server/lib/video-file' import { VideoPathManager } from '@server/lib/video-path-manager' import { approximateIntroOutroAdditionalSize } from '@server/lib/video-studio' import { UserModel } from '@server/models/user/user' @@ -27,12 +28,12 @@ import { } from '@shared/extra-utils' import { VideoStudioEditionPayload, - VideoStudioTaskPayload, + VideoStudioTask, VideoStudioTaskCutPayload, VideoStudioTaskIntroPayload, VideoStudioTaskOutroPayload, - VideoStudioTaskWatermarkPayload, - VideoStudioTask + VideoStudioTaskPayload, + VideoStudioTaskWatermarkPayload } from '@shared/models' import { logger, loggerTagsFactory } from '../../../helpers/logger' @@ -89,7 +90,6 @@ async function processVideoStudioEdition (job: Job) { await move(editionResultPath, outputPath) await createTorrentAndSetInfoHashFromPath(video, newFile, outputPath) - await removeAllFiles(video, newFile) await newFile.save() @@ -197,18 +197,12 @@ async function buildNewFile (video: MVideoId, path: string) { } async function removeAllFiles (video: MVideoWithAllFiles, webTorrentFileException: MVideoFile) { - const hls = video.getHLSPlaylist() - - if (hls) { - await video.removeStreamingPlaylistFiles(hls) - await hls.destroy() - } + await removeHLSPlaylist(video) for (const file of video.VideoFiles) { if (file.id === webTorrentFileException.id) continue - await video.removeWebTorrentFileAndTorrent(file) - await file.destroy() + await removeWebTorrentFile(video, file.id) } } 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 if (payload.isMaxQuality && payload.autoDeleteWebTorrentIfNeeded && CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) { // Remove webtorrent files if not enabled for (const file of video.VideoFiles) { - await video.removeWebTorrentFileAndTorrent(file) + await video.removeWebTorrentFile(file) await file.destroy() } -- cgit v1.2.3