aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r--server/models/video/video.ts30
1 files changed, 25 insertions, 5 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 243871028..eacffe186 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -136,7 +136,8 @@ import {
136 MVideoThumbnailBlacklist, 136 MVideoThumbnailBlacklist,
137 MVideoWithAllFiles, 137 MVideoWithAllFiles,
138 MVideoWithFile, 138 MVideoWithFile,
139 MVideoWithRights 139 MVideoWithRights,
140 MStreamingPlaylistFiles
140} from '../../typings/models' 141} from '../../typings/models'
141import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../typings/models/video/video-file' 142import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../typings/models/video/video-file'
142import { MThumbnail } from '../../typings/models/video/thumbnail' 143import { MThumbnail } from '../../typings/models/video/thumbnail'
@@ -1071,7 +1072,13 @@ export class VideoModel extends Model<VideoModel> {
1071 }) 1072 })
1072 1073
1073 // Remove playlists file 1074 // Remove playlists file
1074 tasks.push(instance.removeStreamingPlaylist()) 1075 if (!Array.isArray(instance.VideoStreamingPlaylists)) {
1076 instance.VideoStreamingPlaylists = await instance.$get('VideoStreamingPlaylists')
1077 }
1078
1079 for (const p of instance.VideoStreamingPlaylists) {
1080 tasks.push(instance.removeStreamingPlaylistFiles(p))
1081 }
1075 } 1082 }
1076 1083
1077 // Do not wait video deletion because we could be in a transaction 1084 // Do not wait video deletion because we could be in a transaction
@@ -2001,11 +2008,24 @@ export class VideoModel extends Model<VideoModel> {
2001 .catch(err => logger.warn('Cannot delete torrent %s.', torrentPath, { err })) 2008 .catch(err => logger.warn('Cannot delete torrent %s.', torrentPath, { err }))
2002 } 2009 }
2003 2010
2004 removeStreamingPlaylist (isRedundancy = false) { 2011 async removeStreamingPlaylistFiles (streamingPlaylist: MStreamingPlaylist, isRedundancy = false) {
2005 const directoryPath = getHLSDirectory(this, isRedundancy) 2012 const directoryPath = getHLSDirectory(this, isRedundancy)
2006 2013
2007 return remove(directoryPath) 2014 await remove(directoryPath)
2008 .catch(err => logger.warn('Cannot delete playlist directory %s.', directoryPath, { err })) 2015
2016 if (isRedundancy !== true) {
2017 let streamingPlaylistWithFiles = streamingPlaylist as MStreamingPlaylistFilesVideo
2018 streamingPlaylistWithFiles.Video = this
2019
2020 if (!Array.isArray(streamingPlaylistWithFiles.VideoFiles)) {
2021 streamingPlaylistWithFiles.VideoFiles = await streamingPlaylistWithFiles.$get('VideoFiles')
2022 }
2023
2024 // Remove physical files and torrents
2025 await Promise.all(
2026 streamingPlaylistWithFiles.VideoFiles.map(file => streamingPlaylistWithFiles.removeTorrent(file))
2027 )
2028 }
2009 } 2029 }
2010 2030
2011 isOutdated () { 2031 isOutdated () {