refac
This commit is contained in:
1 parent
9835b3f1dd
commit
97252fa609
1 file changed
+14
-26
@@ -678,33 +678,21 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
let uploadedCount = 0;
|
let uploadedCount = 0;
|
||||||
const BATCH_SIZE = 3;
|
for (const entry of filesToUpload) {
|
||||||
for (let i = 0; i < filesToUpload.length; i += BATCH_SIZE) {
|
uploadedCount++;
|
||||||
const batch = filesToUpload.slice(i, i + BATCH_SIZE);
|
const displayPath = entry.path ? `${entry.path}/${entry.filename}` : entry.filename;
|
||||||
await Promise.all(
|
syncing = $i18n.t('Uploading {{current}}/{{total}}: {{file}}', {
|
||||||
batch.map(async (entry) => {
|
current: uploadedCount,
|
||||||
uploadedCount++;
|
total: filesToUpload.length,
|
||||||
const displayPath = entry.path ? `${entry.path}/${entry.filename}` : entry.filename;
|
file: displayPath
|
||||||
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, fileObject, {
|
||||||
localStorage.token,
|
knowledge_id: knowledge.id,
|
||||||
fileObject,
|
file_hash: entry.checksum,
|
||||||
{
|
directory_id: entry.path ? createdDirectoryIds[entry.path] : null
|
||||||
knowledge_id: knowledge.id,
|
}).catch(() => null);
|
||||||
file_hash: entry.checksum,
|
|
||||||
directory_id: entry.path ? createdDirectoryIds[entry.path] : null
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
false
|
|
||||||
).catch(() => null);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── 6. Cleanup — remove deleted files + rmdir orphaned directories ──
|
// ── 6. Cleanup — remove deleted files + rmdir orphaned directories ──
|
||||||
|
|||||||
Reference in new issue
Block a user