From 34023e12534f22f28d0b5afc1db3fdf2fd1e7e60 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 10 May 2023 11:16:05 +0200 Subject: Fix S3 live sync Ensure TS chunks referenced in M3U8 playlist are already uploaded on S3 --- .../lib/object-storage/shared/object-storage-helpers.ts | 17 ++++++++++++++++- server/lib/object-storage/videos.ts | 10 ++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) (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 be94b01a8..f517c5f69 100644 --- a/server/lib/object-storage/shared/object-storage-helpers.ts +++ b/server/lib/object-storage/shared/object-storage-helpers.ts @@ -59,6 +59,20 @@ async function storeObject (options: { return uploadToStorage({ objectStorageKey, content: fileStream, bucketInfo, isPrivate }) } +async function storeContent (options: { + content: string + inputPath: string + objectStorageKey: string + bucketInfo: BucketInfo + isPrivate: boolean +}): Promise { + const { content, objectStorageKey, bucketInfo, inputPath, isPrivate } = options + + logger.debug('Uploading %s content to %s%s in bucket %s', inputPath, bucketInfo.PREFIX, objectStorageKey, bucketInfo.BUCKET_NAME, lTags()) + + return uploadToStorage({ objectStorageKey, content, bucketInfo, isPrivate }) +} + // --------------------------------------------------------------------------- async function updateObjectACL (options: { @@ -206,6 +220,7 @@ export { buildKey, storeObject, + storeContent, removeObject, removeObjectByFullKey, @@ -223,7 +238,7 @@ export { // --------------------------------------------------------------------------- async function uploadToStorage (options: { - content: ReadStream + content: ReadStream | string objectStorageKey: string bucketInfo: BucketInfo isPrivate: boolean diff --git a/server/lib/object-storage/videos.ts b/server/lib/object-storage/videos.ts index bfdef94fd..57d978e4c 100644 --- a/server/lib/object-storage/videos.ts +++ b/server/lib/object-storage/videos.ts @@ -42,6 +42,15 @@ function storeHLSFileFromPath (playlist: MStreamingPlaylistVideo, path: string) }) } +function storeHLSFileFromContent (playlist: MStreamingPlaylistVideo, path: string, content: string) { + return storeObject({ + inputPath: path, + objectStorageKey: generateHLSObjectStorageKey(playlist, basename(path)), + bucketInfo: CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS, + isPrivate: playlist.Video.hasPrivateStaticPath() + }) +} + // --------------------------------------------------------------------------- function storeWebTorrentFile (video: MVideo, file: MVideoFile) { @@ -166,6 +175,7 @@ export { storeWebTorrentFile, storeHLSFileFromFilename, storeHLSFileFromPath, + storeHLSFileFromContent, updateWebTorrentFileACL, updateHLSFilesACL, -- cgit v1.2.3