pop schedule a file for a new upload

This commit is contained in:
Abhinav-grd 2021-07-27 14:13:51 +05:30
parent 0641263e5c
commit 0b6aba1856

View file

@ -213,17 +213,20 @@ class UploadService {
const uploadProcesses = []; const uploadProcesses = [];
for ( for (
let i = 0; let i = 0;
i < Math.min(MAX_CONCURRENT_UPLOADS, this.totalFileCount); i < MAX_CONCURRENT_UPLOADS;
i++ i++
) { ) {
this.cryptoWorkers[i] = getDedicatedCryptoWorker(); if (this.filesToBeUploaded.length>0) {
uploadProcesses.push( const fileWithCollection= this.filesToBeUploaded.pop();
this.uploader( this.cryptoWorkers[i] = getDedicatedCryptoWorker();
await new this.cryptoWorkers[i].comlink(), uploadProcesses.push(
new FileReader(), this.uploader(
this.filesToBeUploaded.pop(), await new this.cryptoWorkers[i].comlink(),
), new FileReader(),
); fileWithCollection,
),
);
}
} }
progressBarProps.setUploadStage(UPLOAD_STAGES.UPLOADING); progressBarProps.setUploadStage(UPLOAD_STAGES.UPLOADING);
await Promise.all(uploadProcesses); await Promise.all(uploadProcesses);
@ -245,9 +248,6 @@ class UploadService {
reader: FileReader, reader: FileReader,
fileWithCollection: FileWithCollection, fileWithCollection: FileWithCollection,
) { ) {
if (!fileWithCollection) {
return;
}
const { file: rawFile, collection } = fileWithCollection; const { file: rawFile, collection } = fileWithCollection;
this.fileProgress.set(rawFile.name, 0); this.fileProgress.set(rawFile.name, 0);
this.updateProgressBarUI(); this.updateProgressBarUI();