π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
add file disk caching
Abhinavb2b197a617f8
diff --git a/apps/photos/src/services/downloadManager.ts b/apps/photos/src/services/downloadManager.tsindex a78399c0f7..07d6019182 100644--- a/apps/photos/src/services/downloadManager.ts+++ b/apps/photos/src/services/downloadManager.ts@@ -48,6 +48,8 @@ export interface DownloadClient {downloadFileStream: (file: EnteFile) => Promise<Response>;}+const FILE_CACHE_LIMIT = 5 * 1024 * 1024 * 1024; // 5GB+class DownloadManager {private downloadClient: DownloadClient;private thumbnailCache: LimitedCache;@@ -475,7 +477,7 @@ async function openThumbnailCache() {async function openFileCache() {try {- return await CacheStorageService.open(CACHES.FACE_CROPS);+ return await CacheStorageService.open(CACHES.FILES, FILE_CACHE_LIMIT);} catch (e) {logError(e, 'Failed to open file cache');return null;diff --git a/packages/shared/electron/types.ts b/packages/shared/electron/types.tsindex 710db38e8f..fcf76a4fb4 100644--- a/packages/shared/electron/types.ts+++ b/packages/shared/electron/types.ts@@ -59,7 +59,10 @@ export interface ElectronAPIsType {clearElectronStore: () => void;setEncryptionKey: (encryptionKey: string) => Promise<void>;getEncryptionKey: () => Promise<string>;- openDiskCache: (cacheName: string) => Promise<LimitedCache>;+ openDiskCache: (+ cacheName: string,+ cacheLimit?: number+ ) => Promise<LimitedCache>;deleteDiskCache: (cacheName: string) => Promise<boolean>;logToDisk: (msg: string) => void;convertToJPEG: (diff --git a/packages/shared/storage/cacheStorage/index.ts b/packages/shared/storage/cacheStorage/index.tsindex 9205c2aae7..4a38bd93f7 100644--- a/packages/shared/storage/cacheStorage/index.ts+++ b/packages/shared/storage/cacheStorage/index.ts@@ -3,9 +3,12 @@ import { CacheStorageFactory } from './factory';const SecurityError = 'SecurityError';const INSECURE_OPERATION = 'The operation is insecure.';-async function openCache(cacheName: string) {+async function openCache(cacheName: string, cacheLimit?: number) {try {- return await CacheStorageFactory.getCacheStorage().open(cacheName);+ return await CacheStorageFactory.getCacheStorage().open(+ cacheName,+ cacheLimit+ );} catch (e) {// ignoring insecure operation error, as it is thrown in incognito mode in firefoxif (e.name === SecurityError && e.message === INSECURE_OPERATION) {diff --git a/packages/shared/storage/cacheStorage/types.ts b/packages/shared/storage/cacheStorage/types.tsindex 2920ece105..4dce2084a0 100644--- a/packages/shared/storage/cacheStorage/types.ts+++ b/packages/shared/storage/cacheStorage/types.ts@@ -1,5 +1,5 @@export interface LimitedCacheStorage {- open: (cacheName: string) => Promise<LimitedCache>;+ open: (cacheName: string, cacheLimit?: number) => Promise<LimitedCache>;delete: (cacheName: string) => Promise<boolean>;}