1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 18:29:27 +02:00

Live supports object storage

* Sync live files (segments, master playlist, resolution playlist,
   segment sha file) into object storage
 * Automatically delete them when the live ends
 * Segment sha file is now a file on disk, and not stored in memory
   anymore
This commit is contained in:
Chocobozzz 2022-10-04 10:03:17 +02:00
parent 9c0cdc5047
commit cfd57d2ca0
No known key found for this signature in database
GPG key ID: 583A612D890159BE
21 changed files with 615 additions and 307 deletions

View file

@ -22,6 +22,24 @@ type BucketInfo = {
PREFIX?: string
}
async function listKeysOfPrefix (prefix: string, bucketInfo: BucketInfo) {
const s3Client = getClient()
const commandPrefix = bucketInfo.PREFIX + prefix
const listCommand = new ListObjectsV2Command({
Bucket: bucketInfo.BUCKET_NAME,
Prefix: commandPrefix
})
const listedObjects = await s3Client.send(listCommand)
if (isArray(listedObjects.Contents) !== true) return []
return listedObjects.Contents.map(c => c.Key)
}
// ---------------------------------------------------------------------------
async function storeObject (options: {
inputPath: string
objectStorageKey: string
@ -36,6 +54,8 @@ async function storeObject (options: {
return uploadToStorage({ objectStorageKey, content: fileStream, bucketInfo })
}
// ---------------------------------------------------------------------------
async function removeObject (filename: string, bucketInfo: BucketInfo) {
const command = new DeleteObjectCommand({
Bucket: bucketInfo.BUCKET_NAME,
@ -89,6 +109,8 @@ async function removePrefix (prefix: string, bucketInfo: BucketInfo) {
if (listedObjects.IsTruncated) await removePrefix(prefix, bucketInfo)
}
// ---------------------------------------------------------------------------
async function makeAvailable (options: {
key: string
destination: string
@ -122,7 +144,8 @@ export {
storeObject,
removeObject,
removePrefix,
makeAvailable
makeAvailable,
listKeysOfPrefix
}
// ---------------------------------------------------------------------------