From 46471d4c25f478d36c7f55a4aceb6306d48748fb Mon Sep 17 00:00:00 2001 From: abhinav-grd Date: Wed, 22 Sep 2021 14:52:50 +0530 Subject: [PATCH] Revert "added queue processor to file decryption" This reverts commit 3cab5372e92a7dd140fcfbfb52b7f7b1d9b32a86. --- src/services/fileService.ts | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/services/fileService.ts b/src/services/fileService.ts index 9ef01e6e1..f3fc24ddf 100644 --- a/src/services/fileService.ts +++ b/src/services/fileService.ts @@ -7,7 +7,6 @@ import { Collection } from './collectionService'; import HTTPService from './HTTPService'; import { logError } from 'utils/sentry'; import { decryptFile, sortFiles } from 'utils/file'; -import QueueProcessor from './upload/queueProcessor'; const ENDPOINT = getEndpoint(); const DIFF_LIMIT: number = 1000; @@ -86,7 +85,6 @@ export const NEW_MAGIC_METADATA: MagicMetadata = { header: null, count: 0, }; -const PARALLEL_FILE_DECRYPTION = 20; export const getLocalFiles = async () => { const files: Array = (await localForage.getItem(FILES)) || []; @@ -192,18 +190,17 @@ export const getFiles = async ( 'X-Auth-Token': token, } ); - const fileDecrypter = new QueueProcessor(PARALLEL_FILE_DECRYPTION); - for (let file of resp.data.diff) { - if (!file.isDeleted) { - file = await fileDecrypter.queueUpRequest(() => - decryptFile(file, collection) - ).promise; - if (!file) { - return; - } - } - decryptedFiles.push(file); - } + + decryptedFiles.push( + ...(await Promise.all( + resp.data.diff.map(async (file: File) => { + if (!file.isDeleted) { + file = await decryptFile(file, collection); + } + return file; + }) as Promise[] + )) + ); if (resp.data.diff.length) { time = resp.data.diff.slice(-1)[0].updationTime;