Process files sequentially to avoid too many simultaneous requests

This commit is contained in:
David Montesinos 2025-02-06 16:01:23 +01:00
parent d775b8be72
commit e472850f83

View File

@ -338,8 +338,7 @@ Oqtane.Interop = {
progressbar.value = 0;
}
const uploadFiles = Array.from(fileinput.files).map(file => {
const uploadFile = () => {
const uploadFile = (file) => {
const chunkSize = chunksize * (1024 * 1024);
const totalParts = Math.ceil(file.size / chunkSize);
let partCount = 0;
@ -398,7 +397,7 @@ Oqtane.Interop = {
return new Promise((resolve, reject) => {
function processNextUpload() {
if (partCount >= totalParts) {
if (activeUploads === 0) resolve(); // Done uploading all parts
if (activeUploads === 0) resolve(); // Done uploading all parts in the file
return;
}
@ -419,11 +418,10 @@ Oqtane.Interop = {
});
};
return uploadFile();
});
try {
await Promise.all(uploadFiles);
for (const file of fileinput.files) {
await uploadFile(file);
}
} catch (error) {
success = false;
}