Revert "added queue processor to file decryption"

This reverts commit 3cab5372e9.
This commit is contained in:
abhinav-grd 2021-09-22 14:52:50 +05:30
parent 9a24f617ca
commit 46471d4c25

View file

@ -7,7 +7,6 @@ import { Collection } from './collectionService';
import HTTPService from './HTTPService'; import HTTPService from './HTTPService';
import { logError } from 'utils/sentry'; import { logError } from 'utils/sentry';
import { decryptFile, sortFiles } from 'utils/file'; import { decryptFile, sortFiles } from 'utils/file';
import QueueProcessor from './upload/queueProcessor';
const ENDPOINT = getEndpoint(); const ENDPOINT = getEndpoint();
const DIFF_LIMIT: number = 1000; const DIFF_LIMIT: number = 1000;
@ -86,7 +85,6 @@ export const NEW_MAGIC_METADATA: MagicMetadata = {
header: null, header: null,
count: 0, count: 0,
}; };
const PARALLEL_FILE_DECRYPTION = 20;
export const getLocalFiles = async () => { export const getLocalFiles = async () => {
const files: Array<File> = (await localForage.getItem<File[]>(FILES)) || []; const files: Array<File> = (await localForage.getItem<File[]>(FILES)) || [];
@ -192,18 +190,17 @@ export const getFiles = async (
'X-Auth-Token': token, 'X-Auth-Token': token,
} }
); );
const fileDecrypter = new QueueProcessor(PARALLEL_FILE_DECRYPTION);
for (let file of resp.data.diff) { decryptedFiles.push(
if (!file.isDeleted) { ...(await Promise.all(
file = await fileDecrypter.queueUpRequest(() => resp.data.diff.map(async (file: File) => {
decryptFile(file, collection) if (!file.isDeleted) {
).promise; file = await decryptFile(file, collection);
if (!file) { }
return; return file;
} }) as Promise<File>[]
} ))
decryptedFiles.push(file); );
}
if (resp.data.diff.length) { if (resp.data.diff.length) {
time = resp.data.diff.slice(-1)[0].updationTime; time = resp.data.diff.slice(-1)[0].updationTime;