aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/object-storage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-05-10 11:16:05 +0200
committerChocobozzz <me@florianbigard.com>2023-05-10 11:16:05 +0200
commit34023e12534f22f28d0b5afc1db3fdf2fd1e7e60 (patch)
tree29b219412b79231ac7a62e482982bf1a9a7aada8 /server/lib/object-storage
parentf9eee54f2a601b8db7ebb7c11d149b39170e6d68 (diff)
downloadPeerTube-34023e12534f22f28d0b5afc1db3fdf2fd1e7e60.tar.gz
PeerTube-34023e12534f22f28d0b5afc1db3fdf2fd1e7e60.tar.zst
PeerTube-34023e12534f22f28d0b5afc1db3fdf2fd1e7e60.zip
Fix S3 live sync
Ensure TS chunks referenced in M3U8 playlist are already uploaded on S3
Diffstat (limited to 'server/lib/object-storage')
-rw-r--r--server/lib/object-storage/shared/object-storage-helpers.ts17
-rw-r--r--server/lib/object-storage/videos.ts10
2 files changed, 26 insertions, 1 deletions
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: {
59 return uploadToStorage({ objectStorageKey, content: fileStream, bucketInfo, isPrivate }) 59 return uploadToStorage({ objectStorageKey, content: fileStream, bucketInfo, isPrivate })
60} 60}
61 61
62async function storeContent (options: {
63 content: string
64 inputPath: string
65 objectStorageKey: string
66 bucketInfo: BucketInfo
67 isPrivate: boolean
68}): Promise<string> {
69 const { content, objectStorageKey, bucketInfo, inputPath, isPrivate } = options
70
71 logger.debug('Uploading %s content to %s%s in bucket %s', inputPath, bucketInfo.PREFIX, objectStorageKey, bucketInfo.BUCKET_NAME, lTags())
72
73 return uploadToStorage({ objectStorageKey, content, bucketInfo, isPrivate })
74}
75
62// --------------------------------------------------------------------------- 76// ---------------------------------------------------------------------------
63 77
64async function updateObjectACL (options: { 78async function updateObjectACL (options: {
@@ -206,6 +220,7 @@ export {
206 buildKey, 220 buildKey,
207 221
208 storeObject, 222 storeObject,
223 storeContent,
209 224
210 removeObject, 225 removeObject,
211 removeObjectByFullKey, 226 removeObjectByFullKey,
@@ -223,7 +238,7 @@ export {
223// --------------------------------------------------------------------------- 238// ---------------------------------------------------------------------------
224 239
225async function uploadToStorage (options: { 240async function uploadToStorage (options: {
226 content: ReadStream 241 content: ReadStream | string
227 objectStorageKey: string 242 objectStorageKey: string
228 bucketInfo: BucketInfo 243 bucketInfo: BucketInfo
229 isPrivate: boolean 244 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)
42 }) 42 })
43} 43}
44 44
45function storeHLSFileFromContent (playlist: MStreamingPlaylistVideo, path: string, content: string) {
46 return storeObject({
47 inputPath: path,
48 objectStorageKey: generateHLSObjectStorageKey(playlist, basename(path)),
49 bucketInfo: CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS,
50 isPrivate: playlist.Video.hasPrivateStaticPath()
51 })
52}
53
45// --------------------------------------------------------------------------- 54// ---------------------------------------------------------------------------
46 55
47function storeWebTorrentFile (video: MVideo, file: MVideoFile) { 56function storeWebTorrentFile (video: MVideo, file: MVideoFile) {
@@ -166,6 +175,7 @@ export {
166 storeWebTorrentFile, 175 storeWebTorrentFile,
167 storeHLSFileFromFilename, 176 storeHLSFileFromFilename,
168 storeHLSFileFromPath, 177 storeHLSFileFromPath,
178 storeHLSFileFromContent,
169 179
170 updateWebTorrentFileACL, 180 updateWebTorrentFileACL,
171 updateHLSFilesACL, 181 updateHLSFilesACL,