fix things

This commit is contained in:
Abhinav 2022-02-04 00:26:34 +05:30
parent e7c051ac53
commit 21aab14380
2 changed files with 22 additions and 6 deletions

View file

@ -32,7 +32,6 @@ import {
import { ComlinkWorker } from 'utils/comlink';
import { getFileType } from './readFileService';
import { FILE_TYPE } from 'constants/file';
import { title } from 'process';
import uploadService from './uploadService';
const MAX_CONCURRENT_UPLOADS = 4;
@ -95,6 +94,9 @@ class UploadManager {
if (mediaFiles.length) {
UIService.setUploadStage(UPLOAD_STAGES.START);
await this.extractMetadataFromFiles(mediaFiles);
uploadService.setMetadataAndFileTypeInfoMap(
this.metadataAndFileTypeInfoMap
);
await this.uploadMediaFiles(mediaFiles);
}
UIService.setUploadStage(UPLOAD_STAGES.FINISH);
@ -155,10 +157,15 @@ class UploadManager {
)) || null;
return { fileTypeInfo, metadata };
})();
this.metadataAndFileTypeInfoMap.set(
getMetadataMapKey(collectionID, title),
{ ...{ fileTypeInfo, metadata } }
getMetadataMapKey(collectionID, file.name),
{
fileTypeInfo: { ...fileTypeInfo },
metadata: { ...metadata },
}
);
console.log(this.metadataAndFileTypeInfoMap.keys());
UIService.increaseFileUploaded();
}
} catch (e) {

View file

@ -23,12 +23,20 @@ import {
UploadURL,
MetadataAndFileTypeInfoMap,
ParsedMetadataJSONMap,
ParsedMetadataJSON,
MetadataAndFileTypeInfo,
} from 'types/upload';
class UploadService {
private uploadURLs: UploadURL[] = [];
private parsedMetadataJSONMap: ParsedMetadataJSONMap;
private metadataAndFileTypeInfoMap: MetadataAndFileTypeInfoMap;
private parsedMetadataJSONMap: ParsedMetadataJSONMap = new Map<
string,
ParsedMetadataJSON
>();
private metadataAndFileTypeInfoMap: MetadataAndFileTypeInfoMap = new Map<
string,
MetadataAndFileTypeInfo
>();
private pendingUploadCount: number = 0;
async setFileCount(fileCount: number) {
@ -101,7 +109,8 @@ class UploadService {
}
getFileMetadataAndFileTypeInfo(key: string) {
return this.getFileMetadataAndFileTypeInfo(key);
console.log(this.metadataAndFileTypeInfoMap, key);
return this.metadataAndFileTypeInfoMap.get(key);
}
async encryptFile(