From aa887096f9a305568dc3a846d0c9cdf7e45f1c67 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 25 Oct 2022 14:18:59 +0200 Subject: Correctly delete live files from object storage --- .../lib/object-storage/shared/object-storage-helpers.ts | 9 +++++++-- server/lib/object-storage/videos.ts | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'server/lib/object-storage') diff --git a/server/lib/object-storage/shared/object-storage-helpers.ts b/server/lib/object-storage/shared/object-storage-helpers.ts index d13c25798..3046d76bc 100644 --- a/server/lib/object-storage/shared/object-storage-helpers.ts +++ b/server/lib/object-storage/shared/object-storage-helpers.ts @@ -110,11 +110,15 @@ function updatePrefixACL (options: { function removeObject (objectStorageKey: string, bucketInfo: BucketInfo) { const key = buildKey(objectStorageKey, bucketInfo) - logger.debug('Removing file %s in bucket %s', key, bucketInfo.BUCKET_NAME, lTags()) + return removeObjectByFullKey(key, bucketInfo) +} + +function removeObjectByFullKey (fullKey: string, bucketInfo: BucketInfo) { + logger.debug('Removing file %s in bucket %s', fullKey, bucketInfo.BUCKET_NAME, lTags()) const command = new DeleteObjectCommand({ Bucket: bucketInfo.BUCKET_NAME, - Key: key + Key: fullKey }) return getClient().send(command) @@ -195,6 +199,7 @@ export { storeObject, removeObject, + removeObjectByFullKey, removePrefix, makeAvailable, diff --git a/server/lib/object-storage/videos.ts b/server/lib/object-storage/videos.ts index 003807826..b764e4b22 100644 --- a/server/lib/object-storage/videos.ts +++ b/server/lib/object-storage/videos.ts @@ -11,6 +11,7 @@ import { lTags, makeAvailable, removeObject, + removeObjectByFullKey, removePrefix, storeObject, updateObjectACL, @@ -76,10 +77,18 @@ function removeHLSObjectStorage (playlist: MStreamingPlaylistVideo) { return removePrefix(generateHLSObjectBaseStorageKey(playlist), CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS) } -function removeHLSFileObjectStorage (playlist: MStreamingPlaylistVideo, filename: string) { +function removeHLSFileObjectStorageByFilename (playlist: MStreamingPlaylistVideo, filename: string) { return removeObject(generateHLSObjectStorageKey(playlist, filename), CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS) } +function removeHLSFileObjectStorageByPath (playlist: MStreamingPlaylistVideo, path: string) { + return removeObject(generateHLSObjectStorageKey(playlist, basename(path)), CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS) +} + +function removeHLSFileObjectStorageByFullKey (key: string) { + return removeObjectByFullKey(key, CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS) +} + // --------------------------------------------------------------------------- function removeWebTorrentObjectStorage (videoFile: MVideoFile) { @@ -162,7 +171,10 @@ export { updateHLSFilesACL, removeHLSObjectStorage, - removeHLSFileObjectStorage, + removeHLSFileObjectStorageByFilename, + removeHLSFileObjectStorageByPath, + removeHLSFileObjectStorageByFullKey, + removeWebTorrentObjectStorage, makeWebTorrentFileAvailable, -- cgit v1.2.3