refac
This commit is contained in:
1 parent
73bdf86766
commit
9835b3f1dd
1 file changed
+27
-21
@@ -678,27 +678,33 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
let uploadedCount = 0;
|
let uploadedCount = 0;
|
||||||
for (const entry of filesToUpload) {
|
const BATCH_SIZE = 3;
|
||||||
uploadedCount++;
|
for (let i = 0; i < filesToUpload.length; i += BATCH_SIZE) {
|
||||||
const displayPath = entry.path ? `${entry.path}/${entry.filename}` : entry.filename;
|
const batch = filesToUpload.slice(i, i + BATCH_SIZE);
|
||||||
syncing = $i18n.t('Uploading {{current}}/{{total}}: {{file}}', {
|
await Promise.all(
|
||||||
current: uploadedCount,
|
batch.map(async (entry) => {
|
||||||
total: filesToUpload.length,
|
uploadedCount++;
|
||||||
file: displayPath
|
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 });
|
const fileObject = new File([entry.file], entry.filename, { type: entry.file.type });
|
||||||
await uploadFile(
|
await uploadFile(
|
||||||
localStorage.token,
|
localStorage.token,
|
||||||
fileObject,
|
fileObject,
|
||||||
{
|
{
|
||||||
knowledge_id: knowledge.id,
|
knowledge_id: knowledge.id,
|
||||||
file_hash: entry.checksum,
|
file_hash: entry.checksum,
|
||||||
directory_id: entry.path ? createdDirectoryIds[entry.path] : null
|
directory_id: entry.path ? createdDirectoryIds[entry.path] : null
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
false
|
false
|
||||||
).catch(() => null);
|
).catch(() => null);
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── 6. Cleanup — remove deleted files + rmdir orphaned directories ──
|
// ── 6. Cleanup — remove deleted files + rmdir orphaned directories ──
|
||||||
@@ -1374,7 +1380,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if syncing}
|
{#if syncing}
|
||||||
<div class="mx-2.5 mt-2">
|
<div class="mx-2.5 mt-2.5 -mb-0.5">
|
||||||
<div class="flex items-center gap-2.5 rounded-xl py-2 px-3 bg-gray-50 dark:bg-gray-850">
|
<div class="flex items-center gap-2.5 rounded-xl py-2 px-3 bg-gray-50 dark:bg-gray-850">
|
||||||
<Spinner className="size-3.5 shrink-0" />
|
<Spinner className="size-3.5 shrink-0" />
|
||||||
<div class="text-xs text-gray-500 dark:text-gray-400 truncate">
|
<div class="text-xs text-gray-500 dark:text-gray-400 truncate">
|
||||||
|
|||||||
Reference in new issue
Block a user