show progress for metadata file reading
This commit is contained in:
parent
c6168ea752
commit
f22ef34420
|
@ -157,7 +157,7 @@ class UploadService {
|
|||
filesWithCollectionToUpload.forEach((fileWithCollection) => {
|
||||
let file = fileWithCollection.file;
|
||||
if (file?.name.substr(0, 1) == '.') {
|
||||
//ignore files with name starting with .
|
||||
//ignore files with name starting with . (hidden files)
|
||||
return;
|
||||
}
|
||||
if (
|
||||
|
@ -171,18 +171,25 @@ class UploadService {
|
|||
metadataFiles.push(fileWithCollection.file);
|
||||
}
|
||||
});
|
||||
this.totalFileCount = actualFiles.length;
|
||||
this.perFileProgress = 100 / actualFiles.length;
|
||||
this.filesToBeUploaded = actualFiles;
|
||||
|
||||
progressBarProps.setUploadStage(
|
||||
UPLOAD_STAGES.READING_GOOGLE_METADATA_FILES
|
||||
);
|
||||
this.totalFileCount = metadataFiles.length;
|
||||
this.perFileProgress = 100 / metadataFiles.length;
|
||||
this.filesCompleted = 0;
|
||||
|
||||
for (const rawFile of metadataFiles) {
|
||||
await this.seedMetadataMap(rawFile);
|
||||
this.filesCompleted++;
|
||||
this.updateProgressBarUI();
|
||||
}
|
||||
|
||||
progressBarProps.setUploadStage(UPLOAD_STAGES.UPLOADING);
|
||||
this.totalFileCount = actualFiles.length;
|
||||
this.perFileProgress = 100 / actualFiles.length;
|
||||
this.filesCompleted = 0;
|
||||
this.updateProgressBarUI();
|
||||
try {
|
||||
await this.fetchUploadURLs();
|
||||
|
@ -226,10 +233,12 @@ class UploadService {
|
|||
try {
|
||||
let file: FileInMemory = await this.readFile(reader, rawFile);
|
||||
if (this.fileAlreadyInCollection(file, collection)) {
|
||||
// set progress to -2 indicating that file upload was skipped
|
||||
this.fileProgress.set(rawFile.name, FILE_UPLOAD_SKIPPED);
|
||||
this.updateProgressBarUI();
|
||||
await WaitFor2Seconds();
|
||||
this.fileProgress.set(rawFile.name, FILE_UPLOAD_COMPLETED);
|
||||
// remove completed files for file progress list
|
||||
this.fileProgress.delete(rawFile.name);
|
||||
return;
|
||||
}
|
||||
let {
|
||||
|
@ -254,7 +263,7 @@ class UploadService {
|
|||
backupedFile = null;
|
||||
await this.uploadFile(uploadFile);
|
||||
uploadFile = null;
|
||||
this.fileProgress.set(rawFile.name, FILE_UPLOAD_COMPLETED);
|
||||
this.fileProgress.delete(rawFile.name);
|
||||
} catch (e) {
|
||||
console.error('file upload failed with error', e);
|
||||
ErrorHandler(e);
|
||||
|
@ -262,6 +271,7 @@ class UploadService {
|
|||
`Uploading Failed for File - ${rawFile.name}`
|
||||
);
|
||||
this.uploadErrors.push(error);
|
||||
// set progress to -1 indicating that file upload failed but keep it to show in the file-upload list progress
|
||||
this.fileProgress.set(rawFile.name, FILE_UPLOAD_FAILED);
|
||||
} finally {
|
||||
this.filesCompleted++;
|
||||
|
@ -286,9 +296,13 @@ class UploadService {
|
|||
finished: this.filesCompleted,
|
||||
total: this.totalFileCount,
|
||||
});
|
||||
let percentComplete = 0;
|
||||
let percentComplete = this.perFileProgress * this.filesCompleted;
|
||||
if (this.fileProgress) {
|
||||
for (let [_, progress] of this.fileProgress) {
|
||||
//filter negative indicator values during percentComplete calculation
|
||||
if (progress < 0) {
|
||||
continue;
|
||||
}
|
||||
percentComplete += (this.perFileProgress * progress) / 100;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue