diff --git a/app/(dashboard)/settings/migration/page.tsx b/app/(dashboard)/settings/migration/page.tsx index 189936c..9e65120 100644 --- a/app/(dashboard)/settings/migration/page.tsx +++ b/app/(dashboard)/settings/migration/page.tsx @@ -140,7 +140,10 @@ export default function MigrationPage() { if (!toMigrate.length) return; setMigrating(true); - for (const file of toMigrate) { + // Process in batches of CONCURRENCY to upload multiple files in parallel + const CONCURRENCY = 5; + + const migrateOne = async (file: FileEntry) => { setStatuses((prev) => new Map(prev).set(file.key, "uploading")); try { const res = await fetch("/api/admin/migration", { @@ -151,7 +154,6 @@ export default function MigrationPage() { const data = await res.json(); if (!res.ok) throw new Error(data.error ?? "Upload failed"); setStatuses((prev) => new Map(prev).set(file.key, "done")); - // Mark as synced in the file list setFiles((prev) => prev.map((f) => (f.key === file.key ? { ...f, hetznerExists: true } : f)) ); @@ -161,6 +163,11 @@ export default function MigrationPage() { new Map(prev).set(file.key, e instanceof Error ? e.message : "Failed") ); } + }; + + // Run in batches of CONCURRENCY + for (let i = 0; i < toMigrate.length; i += CONCURRENCY) { + await Promise.all(toMigrate.slice(i, i + CONCURRENCY).map(migrateOne)); } setMigrating(false);