diff --git a/api/src/controllers/seed/images.ts b/api/src/controllers/seed/images.ts index f7174096..26d42af9 100644 --- a/api/src/controllers/seed/images.ts +++ b/api/src/controllers/seed/images.ts @@ -100,7 +100,11 @@ export const processImages = record("processImages", async () => { let found = true; while (found) { - found = await processOne(); + // run 10 downloads at the same time, + // if one of them couldn't find an item the queue is empty. + found = !( + await Promise.all([new Array(10)].map(() => processOne())) + ).includes(false); } running = false; } diff --git a/api/src/index.ts b/api/src/index.ts index 5e021e65..aaa8ff11 100644 --- a/api/src/index.ts +++ b/api/src/index.ts @@ -7,10 +7,7 @@ import { comment } from "./utils"; await migrate(); -// run image processor task in background -for (let i = 0; i < 10; i++) { - processImages(); -} +processImages(); const app = new Elysia() .use(