Skip to content

armgit / ente

Public Imported from GitHub
0

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

Create alternate code path

Manav Rathi6cd795e29c1a
diff --git a/web/apps/photos/src/services/download/index.ts b/web/apps/photos/src/services/download/index.ts
index 80e6fe8f18..c647e39fb8 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<DedicatedCryptoWorker>;
diff --git a/web/packages/next/cache.ts b/web/packages/next/cache.ts
index 4aba7ea36b..5cf4083612 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<Response>;
+ get: (key: string) => Promise<Uint8Array | undefined>;
+ match: (key: string) => Promise<Response | undefined>;
/**
* 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<EnteCache> =>
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);