diff options
author | Chocobozzz <me@florianbigard.com> | 2022-07-29 14:50:41 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-08-01 14:55:10 +0200 |
commit | 1bb4c9ab2e8b3b3022351b33a82a5e527fa5d4d7 (patch) | |
tree | a6554ee0a3ccc2ae402665b2ecf57bb38fd0ed72 /server/models/video/video.ts | |
parent | 12d84abeca4917d2f1e3f308010bfcd56d37cb7c (diff) | |
download | PeerTube-1bb4c9ab2e8b3b3022351b33a82a5e527fa5d4d7.tar.gz PeerTube-1bb4c9ab2e8b3b3022351b33a82a5e527fa5d4d7.tar.zst PeerTube-1bb4c9ab2e8b3b3022351b33a82a5e527fa5d4d7.zip |
Add ability to delete a specific video file
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r-- | server/models/video/video.ts | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 7e9bb4db4..b8e383502 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -28,7 +28,7 @@ import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation | |||
28 | import { LiveManager } from '@server/lib/live/live-manager' | 28 | import { LiveManager } from '@server/lib/live/live-manager' |
29 | import { removeHLSFileObjectStorage, removeHLSObjectStorage, removeWebTorrentObjectStorage } from '@server/lib/object-storage' | 29 | import { removeHLSFileObjectStorage, removeHLSObjectStorage, removeWebTorrentObjectStorage } from '@server/lib/object-storage' |
30 | import { tracer } from '@server/lib/opentelemetry/tracing' | 30 | import { tracer } from '@server/lib/opentelemetry/tracing' |
31 | import { getHLSDirectory, getHLSRedundancyDirectory } from '@server/lib/paths' | 31 | import { getHLSDirectory, getHLSRedundancyDirectory, getHlsResolutionPlaylistFilename } from '@server/lib/paths' |
32 | import { VideoPathManager } from '@server/lib/video-path-manager' | 32 | import { VideoPathManager } from '@server/lib/video-path-manager' |
33 | import { getServerActor } from '@server/models/application/application' | 33 | import { getServerActor } from '@server/models/application/application' |
34 | import { ModelCache } from '@server/models/model-cache' | 34 | import { ModelCache } from '@server/models/model-cache' |
@@ -769,7 +769,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> { | |||
769 | 769 | ||
770 | // Remove physical files and torrents | 770 | // Remove physical files and torrents |
771 | instance.VideoFiles.forEach(file => { | 771 | instance.VideoFiles.forEach(file => { |
772 | tasks.push(instance.removeWebTorrentFileAndTorrent(file)) | 772 | tasks.push(instance.removeWebTorrentFile(file)) |
773 | }) | 773 | }) |
774 | 774 | ||
775 | // Remove playlists file | 775 | // Remove playlists file |
@@ -1783,7 +1783,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> { | |||
1783 | .concat(toAdd) | 1783 | .concat(toAdd) |
1784 | } | 1784 | } |
1785 | 1785 | ||
1786 | removeWebTorrentFileAndTorrent (videoFile: MVideoFile, isRedundancy = false) { | 1786 | removeWebTorrentFile (videoFile: MVideoFile, isRedundancy = false) { |
1787 | const filePath = isRedundancy | 1787 | const filePath = isRedundancy |
1788 | ? VideoPathManager.Instance.getFSRedundancyVideoFilePath(this, videoFile) | 1788 | ? VideoPathManager.Instance.getFSRedundancyVideoFilePath(this, videoFile) |
1789 | : VideoPathManager.Instance.getFSVideoFileOutputPath(this, videoFile) | 1789 | : VideoPathManager.Instance.getFSVideoFileOutputPath(this, videoFile) |
@@ -1829,8 +1829,12 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> { | |||
1829 | await videoFile.removeTorrent() | 1829 | await videoFile.removeTorrent() |
1830 | await remove(filePath) | 1830 | await remove(filePath) |
1831 | 1831 | ||
1832 | const resolutionFilename = getHlsResolutionPlaylistFilename(videoFile.filename) | ||
1833 | await remove(VideoPathManager.Instance.getFSHLSOutputPath(this, resolutionFilename)) | ||
1834 | |||
1832 | if (videoFile.storage === VideoStorage.OBJECT_STORAGE) { | 1835 | if (videoFile.storage === VideoStorage.OBJECT_STORAGE) { |
1833 | await removeHLSFileObjectStorage(streamingPlaylist.withVideo(this), videoFile.filename) | 1836 | await removeHLSFileObjectStorage(streamingPlaylist.withVideo(this), videoFile.filename) |
1837 | await removeHLSFileObjectStorage(streamingPlaylist.withVideo(this), resolutionFilename) | ||
1834 | } | 1838 | } |
1835 | } | 1839 | } |
1836 | 1840 | ||