aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/object-storage/shared/object-storage-helpers.ts15
1 files changed, 10 insertions, 5 deletions
diff --git a/server/lib/object-storage/shared/object-storage-helpers.ts b/server/lib/object-storage/shared/object-storage-helpers.ts
index 05b52f412..d13c25798 100644
--- a/server/lib/object-storage/shared/object-storage-helpers.ts
+++ b/server/lib/object-storage/shared/object-storage-helpers.ts
@@ -1,3 +1,4 @@
1import { map } from 'bluebird'
1import { createReadStream, createWriteStream, ensureDir, ReadStream } from 'fs-extra' 2import { createReadStream, createWriteStream, ensureDir, ReadStream } from 'fs-extra'
2import { dirname } from 'path' 3import { dirname } from 'path'
3import { Readable } from 'stream' 4import { Readable } from 'stream'
@@ -93,6 +94,8 @@ function updatePrefixACL (options: {
93 prefix, 94 prefix,
94 bucketInfo, 95 bucketInfo,
95 commandBuilder: obj => { 96 commandBuilder: obj => {
97 logger.debug('Updating ACL of %s inside prefix %s in bucket %s', obj.Key, prefix, bucketInfo.BUCKET_NAME, lTags())
98
96 return new PutObjectAclCommand({ 99 return new PutObjectAclCommand({
97 Bucket: bucketInfo.BUCKET_NAME, 100 Bucket: bucketInfo.BUCKET_NAME,
98 Key: obj.Key, 101 Key: obj.Key,
@@ -117,7 +120,7 @@ function removeObject (objectStorageKey: string, bucketInfo: BucketInfo) {
117 return getClient().send(command) 120 return getClient().send(command)
118} 121}
119 122
120function removePrefix (prefix: string, bucketInfo: BucketInfo) { 123async function removePrefix (prefix: string, bucketInfo: BucketInfo) {
121 // FIXME: use bulk delete when s3ninja will support this operation 124 // FIXME: use bulk delete when s3ninja will support this operation
122 125
123 logger.debug('Removing prefix %s in bucket %s', prefix, bucketInfo.BUCKET_NAME, lTags()) 126 logger.debug('Removing prefix %s in bucket %s', prefix, bucketInfo.BUCKET_NAME, lTags())
@@ -126,6 +129,8 @@ function removePrefix (prefix: string, bucketInfo: BucketInfo) {
126 prefix, 129 prefix,
127 bucketInfo, 130 bucketInfo,
128 commandBuilder: obj => { 131 commandBuilder: obj => {
132 logger.debug('Removing %s inside prefix %s in bucket %s', obj.Key, prefix, bucketInfo.BUCKET_NAME, lTags())
133
129 return new DeleteObjectCommand({ 134 return new DeleteObjectCommand({
130 Bucket: bucketInfo.BUCKET_NAME, 135 Bucket: bucketInfo.BUCKET_NAME,
131 Key: obj.Key 136 Key: obj.Key
@@ -259,7 +264,7 @@ async function applyOnPrefix (options: {
259 264
260 const s3Client = getClient() 265 const s3Client = getClient()
261 266
262 const commandPrefix = bucketInfo.PREFIX + prefix 267 const commandPrefix = buildKey(prefix, bucketInfo)
263 const listCommand = new ListObjectsV2Command({ 268 const listCommand = new ListObjectsV2Command({
264 Bucket: bucketInfo.BUCKET_NAME, 269 Bucket: bucketInfo.BUCKET_NAME,
265 Prefix: commandPrefix, 270 Prefix: commandPrefix,
@@ -275,11 +280,11 @@ async function applyOnPrefix (options: {
275 throw new Error(message) 280 throw new Error(message)
276 } 281 }
277 282
278 for (const object of listedObjects.Contents) { 283 await map(listedObjects.Contents, object => {
279 const command = commandBuilder(object) 284 const command = commandBuilder(object)
280 285
281 await s3Client.send(command) 286 return s3Client.send(command)
282 } 287 }, { concurrency: 10 })
283 288
284 // Repeat if not all objects could be listed at once (limit of 1000?) 289 // Repeat if not all objects could be listed at once (limit of 1000?)
285 if (listedObjects.IsTruncated) { 290 if (listedObjects.IsTruncated) {