diff --git a/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte b/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte index 8042dbfe1b..83ac79febb 100644 --- a/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte +++ b/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte @@ -678,27 +678,33 @@ ); let uploadedCount = 0; - for (const entry of filesToUpload) { - uploadedCount++; - const displayPath = entry.path ? `${entry.path}/${entry.filename}` : entry.filename; - syncing = $i18n.t('Uploading {{current}}/{{total}}: {{file}}', { - current: uploadedCount, - total: filesToUpload.length, - file: displayPath - }); + const BATCH_SIZE = 3; + for (let i = 0; i < filesToUpload.length; i += BATCH_SIZE) { + const batch = filesToUpload.slice(i, i + BATCH_SIZE); + await Promise.all( + batch.map(async (entry) => { + uploadedCount++; + const displayPath = entry.path ? `${entry.path}/${entry.filename}` : entry.filename; + syncing = $i18n.t('Uploading {{current}}/{{total}}: {{file}}', { + current: uploadedCount, + total: filesToUpload.length, + file: displayPath + }); - const fileObject = new File([entry.file], entry.filename, { type: entry.file.type }); - await uploadFile( - localStorage.token, - fileObject, - { - knowledge_id: knowledge.id, - file_hash: entry.checksum, - directory_id: entry.path ? createdDirectoryIds[entry.path] : null - }, - null, - false - ).catch(() => null); + const fileObject = new File([entry.file], entry.filename, { type: entry.file.type }); + await uploadFile( + localStorage.token, + fileObject, + { + knowledge_id: knowledge.id, + file_hash: entry.checksum, + directory_id: entry.path ? createdDirectoryIds[entry.path] : null + }, + null, + false + ).catch(() => null); + }) + ); } // ── 6. Cleanup — remove deleted files + rmdir orphaned directories ── @@ -1374,7 +1380,7 @@ {#if syncing} -