Skip to content

Commit 3ec3b80

Browse files
committed
⚡ use Promise.all
1 parent e59f60e commit 3ec3b80

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: services/ipos/src/routes/pinning.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,13 @@ app.post('/pinFile', vValidator('form', pinFileRequestSchema), async (c) => {
9191
},
9292
})
9393

94+
const promises: Promise<R2Object | null>[] = []
9495
for (const { file } of files) {
9596
const path = `${cid}/${file.name}`
96-
c.executionCtx.waitUntil(c.env.BUCKET.put(keyOf(path), file))
97+
promises.push(c.env.BUCKET.put(keyOf(path), file))
9798
}
9899

100+
c.executionCtx.waitUntil(Promise.allSettled(promises))
99101
} else {
100102
const { content, file: f } = files[0]
101103
cid = (await hashOf(content)).toV0().toString()

0 commit comments

Comments
 (0)