From d64113976bd56cb4e9ce41aa04904e878ed4a6f7 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 23 Nov 2024 07:52:22 +0530 Subject: [PATCH] Remove dead code --- web/packages/new/photos/services/download.ts | 47 +++----------------- 1 file changed, 6 insertions(+), 41 deletions(-) diff --git a/web/packages/new/photos/services/download.ts b/web/packages/new/photos/services/download.ts index 2fcb7489f3..7d15ad9444 100644 --- a/web/packages/new/photos/services/download.ts +++ b/web/packages/new/photos/services/download.ts @@ -80,13 +80,6 @@ class DownloadManagerImpl { private downloadClient: DownloadClient | undefined; /** Local cache for thumbnails. Might not be available. */ private thumbnailCache?: BlobCache; - /** - * Local cache for the files themselves. - * - * Only available when we're running in the desktop app. - */ - private fileCache?: BlobCache; - private fileObjectURLPromises = new Map>(); private fileConversionPromises = new Map>(); private thumbnailObjectURLPromises = new Map< @@ -112,13 +105,6 @@ class DownloadManagerImpl { e, ); } - // TODO (MR): Revisit full file caching cf disk space usage - // try { - // if (isElectron()) this.fileCache = await cache("files"); - // } catch (e) { - // log.error("Failed to open file cache, will continue without it", e); - // } - this.ready = true; } @@ -308,25 +294,15 @@ class DownloadManagerImpl { file.info?.fileSize ?? 0, ); - const cacheKey = file.id.toString(); - if ( file.metadata.fileType === FileType.image || file.metadata.fileType === FileType.livePhoto ) { - const cachedBlob = await this.fileCache?.get(cacheKey); - let encryptedArrayBuffer = await cachedBlob?.arrayBuffer(); - if (!encryptedArrayBuffer) { - const array = await downloadClient.downloadFile( - file, - onDownloadProgress, - ); - encryptedArrayBuffer = array.buffer; - await this.fileCache?.put( - cacheKey, - new Blob([encryptedArrayBuffer]), - ); - } + const array = await downloadClient.downloadFile( + file, + onDownloadProgress, + ); + const encryptedArrayBuffer = array.buffer; this.clearDownloadProgress(file.id); const decrypted = await decryptStreamBytes( @@ -339,18 +315,7 @@ class DownloadManagerImpl { return new Response(decrypted).body; } - const cachedBlob = await this.fileCache?.get(cacheKey); - let res: Response; - if (cachedBlob) res = new Response(cachedBlob); - else { - res = await downloadClient.downloadFileStream(file); - // We don't have a files cache currently, so this was already a - // no-op. But even if we had a cache, this seems sus, because - // res.blob() will read the stream and I'd think then trying to do - // the subsequent read of the stream again below won't work. - - // this.fileCache?.put(cacheKey, await res.blob()); - } + const res = await downloadClient.downloadFileStream(file); const body = res.body; if (!body) return null; const reader = body.getReader();