1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-06 11:59:58 +02:00

Fix S3 live sync

Ensure TS chunks referenced in M3U8 playlist are already uploaded on S3
This commit is contained in:
Chocobozzz 2023-05-10 11:16:05 +02:00
parent f9eee54f2a
commit 34023e1253
No known key found for this signature in database
GPG key ID: 583A612D890159BE
4 changed files with 72 additions and 30 deletions

View file

@ -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<string> {
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

View file

@ -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,