From 8180f60477e99c4fd70ce25729d1ca65155a6686 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 12 Jan 2023 08:41:16 +0100 Subject: Fix ACL incompatibility with some s3 providers We'll move to another method in the future See https://github.com/Chocobozzz/PeerTube/issues/5497 --- .../object-storage/shared/object-storage-helpers.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'server/lib/object-storage/shared/object-storage-helpers.ts') diff --git a/server/lib/object-storage/shared/object-storage-helpers.ts b/server/lib/object-storage/shared/object-storage-helpers.ts index 8dff08ab4..be94b01a8 100644 --- a/server/lib/object-storage/shared/object-storage-helpers.ts +++ b/server/lib/object-storage/shared/object-storage-helpers.ts @@ -61,13 +61,16 @@ async function storeObject (options: { // --------------------------------------------------------------------------- -function updateObjectACL (options: { +async function updateObjectACL (options: { objectStorageKey: string bucketInfo: BucketInfo isPrivate: boolean }) { const { objectStorageKey, bucketInfo, isPrivate } = options + const acl = getACL(isPrivate) + if (!acl) return + const key = buildKey(objectStorageKey, bucketInfo) logger.debug('Updating ACL file %s in bucket %s', key, bucketInfo.BUCKET_NAME, lTags()) @@ -75,10 +78,10 @@ function updateObjectACL (options: { const command = new PutObjectAclCommand({ Bucket: bucketInfo.BUCKET_NAME, Key: key, - ACL: getACL(isPrivate) + ACL: acl }) - return getClient().send(command) + await getClient().send(command) } function updatePrefixACL (options: { @@ -88,6 +91,9 @@ function updatePrefixACL (options: { }) { const { prefix, bucketInfo, isPrivate } = options + const acl = getACL(isPrivate) + if (!acl) return + logger.debug('Updating ACL of files in prefix %s in bucket %s', prefix, bucketInfo.BUCKET_NAME, lTags()) return applyOnPrefix({ @@ -99,7 +105,7 @@ function updatePrefixACL (options: { return new PutObjectAclCommand({ Bucket: bucketInfo.BUCKET_NAME, Key: obj.Key, - ACL: getACL(isPrivate) + ACL: acl }) } }) @@ -227,10 +233,12 @@ async function uploadToStorage (options: { const input: PutObjectCommandInput = { Body: content, Bucket: bucketInfo.BUCKET_NAME, - Key: buildKey(objectStorageKey, bucketInfo), - ACL: getACL(isPrivate) + Key: buildKey(objectStorageKey, bucketInfo) } + const acl = getACL(isPrivate) + if (acl) input.ACL = acl + const parallelUploads3 = new Upload({ client: getClient(), queueSize: 4, -- cgit v1.2.3