Skip to content

Commit

Permalink
Create a promise per rename operation
Browse files Browse the repository at this point in the history
  • Loading branch information
bosschaert committed May 27, 2024
1 parent 647e437 commit dbdd5e3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
9 changes: 2 additions & 7 deletions src/storage/object/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,10 @@ export default async function copyObject(env, daCtx, details) {
const resp = await client.send(command);

const { Contents = [], NextContinuationToken } = resp;

sourceKeys.push(...Contents.map(({ Key }) => Key));

await Promise.all(
new Array(1).fill(null).map(async () => {
while (sourceKeys.length) {
await copyFile(client, daCtx.org, sourceKeys.pop(), details);
}
}),
);
await Promise.all(sourceKeys.map((key) => copyFile(client, daCtx.org, key, details)));

ContinuationToken = NextContinuationToken;
} catch (e) {
Expand Down
8 changes: 1 addition & 7 deletions src/storage/object/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,7 @@ export default async function deleteObjects(env, daCtx) {
const { Contents = [], NextContinuationToken } = resp;
sourceKeys.push(...Contents.map(({ Key }) => Key));

await Promise.all(
new Array(1).fill(null).map(async () => {
while (sourceKeys.length) {
await deleteObject(client, daCtx.org, sourceKeys.pop());
}
}),
);
await Promise.all(sourceKeys.map((key) => deleteObject(client, daCtx.org, key)));

ContinuationToken = NextContinuationToken;
} catch (e) {
Expand Down

0 comments on commit dbdd5e3

Please sign in to comment.