diff --git a/machines/store.ts b/machines/store.ts index ee7cb76f82..1cdf4a7ca7 100644 --- a/machines/store.ts +++ b/machines/store.ts @@ -24,7 +24,6 @@ import { isHardwareKeystoreExists, } from '../shared/cryptoutil/cryptoUtil'; import {VCMetadata} from '../shared/VCMetadata'; -import FileStorage, {getFilePath} from '../shared/fileStorage'; export const keyinvalidatedString = 'Key Invalidated due to biometric enrollment'; @@ -173,7 +172,7 @@ export const storeMachine = }, }, ready: { - entry: ['notifyParent', 'cacheVCFilesData'], + entry: 'notifyParent', invoke: { src: 'store', id: '_store', @@ -259,18 +258,6 @@ export const storeMachine = setEncryptionKey: model.assign({ encryptionKey: (_, event) => event.key, }), - - cacheVCFilesData: context => { - getItem(MY_VCS_STORE_KEY, [], context.encryptionKey).then(vcList => { - if (vcList) { - vcList?.forEach((vcMetadataStr: string) => { - const vcKey = - VCMetadata.fromVcMetadataString(vcMetadataStr).getVcKey(); - FileStorage.readAndCacheFile(getFilePath(vcKey)); - }); - } - }); - }, }, services: { diff --git a/shared/fileStorage.ts b/shared/fileStorage.ts index 3863e365a0..426f121977 100644 --- a/shared/fileStorage.ts +++ b/shared/fileStorage.ts @@ -24,34 +24,6 @@ class FileStorage { return await readFile(path, 'utf8'); } - async readFromCacheFile(path: string) { - if (this.cache[path]?.data) { - const count = this.cache[path]?.count ?? 0; - const data = this.cache[path]?.data; - - if (count != undefined && count <= 1) { - this.cache[path] = {}; - } else { - this.cache[path].count = count - 1; - } - - return data; - } - - return this.readFile(path); - } - - async readAndCacheFile(path: string, useCount: number = 1) { - const data = await this.readFile(path); - - this.cache[path] = { - data, - count: useCount, - }; - - return data; - } - async writeFile(path: string, data: string) { return await writeFile(path, data, 'utf8'); } diff --git a/shared/storage.ts b/shared/storage.ts index 1d3696759f..59fc911c21 100644 --- a/shared/storage.ts +++ b/shared/storage.ts @@ -153,7 +153,7 @@ class Storage { } private static async readVCFromFile(key: string) { - return await FileStorage.readFromCacheFile(getFilePath(key)); + return await FileStorage.readFile(getFilePath(key)); } private static async storeVC(key: string, data: string) {