From 3e14a674ac549fc35276948724c41fe7306b91d3 Mon Sep 17 00:00:00 2001 From: Jaret Burkett Date: Sat, 26 Jul 2025 09:07:30 -0600 Subject: [PATCH] Fix upload progress for datasets in the ui --- ui/src/app/api/datasets/upload/route.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/ui/src/app/api/datasets/upload/route.ts b/ui/src/app/api/datasets/upload/route.ts index 0f7836fd..51aff81f 100644 --- a/ui/src/app/api/datasets/upload/route.ts +++ b/ui/src/app/api/datasets/upload/route.ts @@ -22,19 +22,21 @@ export async function POST(request: NextRequest) { const uploadDir = join(datasetsPath, datasetName); await mkdir(uploadDir, { recursive: true }); - const savedFiles = await Promise.all( - files.map(async (file: any) => { - const bytes = await file.arrayBuffer(); - const buffer = Buffer.from(bytes); + const savedFiles: string[] = []; + + // Process files sequentially to avoid overwhelming the system + for (let i = 0; i < files.length; i++) { + const file = files[i] as any; + const bytes = await file.arrayBuffer(); + const buffer = Buffer.from(bytes); - // Clean filename and ensure it's unique - const fileName = file.name.replace(/[^a-zA-Z0-9.-]/g, '_'); - const filePath = join(uploadDir, fileName); + // Clean filename and ensure it's unique + const fileName = file.name.replace(/[^a-zA-Z0-9.-]/g, '_'); + const filePath = join(uploadDir, fileName); - await writeFile(filePath, buffer); - return fileName; - }), - ); + await writeFile(filePath, buffer); + savedFiles.push(fileName); + } return NextResponse.json({ message: 'Files uploaded successfully',