diff --git a/web/apps/photos/src/services/download/index.ts b/web/apps/photos/src/services/download/index.ts index 80e6fe8f1..c647e39fb 100644 --- a/web/apps/photos/src/services/download/index.ts +++ b/web/apps/photos/src/services/download/index.ts @@ -61,7 +61,6 @@ class DownloadManagerImpl { * * Only available when we're running in the desktop app. */ - // disk cache is only available on electron private fileCache?: EnteCache; private cryptoWorker: Remote; diff --git a/web/packages/next/cache.ts b/web/packages/next/cache.ts index 4aba7ea36..5cf408361 100644 --- a/web/packages/next/cache.ts +++ b/web/packages/next/cache.ts @@ -57,7 +57,8 @@ export interface EnteCache { /** * Get the data corresponding to {@link key} (if found) from the cache. */ - match: (key: string) => Promise; + get: (key: string) => Promise; + match: (key: string) => Promise; /** * Add the given {@link key}-value ({@link data}) pair to the cache. */ @@ -78,13 +79,18 @@ export interface EnteCache { * {@link CacheName} which group related data and allow us to use the same key * across namespaces. */ -export const openCache = async (name: CacheName) => +export const openCache = async (name: CacheName): Promise => isElectron() ? openOPFSCacheWeb(name) : openWebCache(name); /** An implementation of {@link EnteCache} using Web Cache APIs */ const openWebCache = async (name: CacheName) => { const cache = await caches.open(name); return { + get: async (key: string) => { + // return cache.match(key); + const _ = await cache.match(key); + return undefined; + }, match: (key: string) => { return cache.match(key); }, @@ -115,6 +121,10 @@ const openOPFSCacheWeb = async (name: CacheName) => { const _cache = await _caches.getDirectoryHandle(name, { create: true }); return { + get: async (key: string) => { + const _ = await cache.match(key); + return undefined; + }, match: (key: string) => { // try { // const fileHandle = _cache.getFileHandle(key);