Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix thumbCache opened multiple times

Abhinav6892b039052c
diff --git a/packages/shared/storage/cacheStorage/helpers.ts b/packages/shared/storage/cacheStorage/helpers.ts
index 5002b9b0de..7ae1026845 100644
--- a/packages/shared/storage/cacheStorage/helpers.ts
+++ b/packages/shared/storage/cacheStorage/helpers.ts
@@ -1,6 +1,7 @@
import { CACHES } from './constants';
import { CacheStorageService } from '.';
import { logError } from '@ente/shared/sentry';
+import { LimitedCache } from './types';
export async function cached(
cacheName: string,
@@ -27,12 +28,16 @@ export async function cached(
return result;
}
+let thumbCache: LimitedCache;
+
export async function getBlobFromCache(
cacheName: string,
url: string
): Promise<Blob> {
- const cache = await CacheStorageService.open(cacheName);
- const response = await cache.match(url);
+ if (!thumbCache) {
+ thumbCache = await CacheStorageService.open(cacheName);
+ }
+ const response = await thumbCache.match(url);
if (!response) {
return undefined;
}