π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
use cached thumbnail if present
Abhinav2eae19868caf
diff --git a/apps/photos/src/services/clipService.ts b/apps/photos/src/services/clipService.tsindex f22b387b13..d143ff11c4 100644--- a/apps/photos/src/services/clipService.ts+++ b/apps/photos/src/services/clipService.ts@@ -194,7 +194,15 @@ class ClipServiceImpl {if (!token) {return;}- const thumb = await downloadManager.downloadThumb(token, file);+ let thumb: Uint8Array;+ const thumbURL = await downloadManager.getCachedThumbnail(file);+ if (thumbURL) {+ thumb = await fetch(thumbURL)+ .then((response) => response.arrayBuffer())+ .then((buffer) => new Uint8Array(buffer));+ } else {+ thumb = await downloadManager.downloadThumb(token, file);+ }const embedding = await this.electronAPIs.computeImageEmbedding(thumb);return embedding;};diff --git a/apps/photos/src/services/downloadManager.ts b/apps/photos/src/services/downloadManager.tsindex dac29b5a9c..b7d269e41d 100644--- a/apps/photos/src/services/downloadManager.ts+++ b/apps/photos/src/services/downloadManager.ts@@ -31,30 +31,29 @@ class DownloadManager {private progressUpdater: (value: Map<number, number>) => void = () => {};+ private thumbnailCache: LimitedCache;+setProgressUpdater(progressUpdater: (value: Map<number, number>) => void) {this.progressUpdater = progressUpdater;}private async getThumbnailCache() {try {- const thumbnailCache = await CacheStorageService.open(- CACHES.THUMBS- );- return thumbnailCache;+ if (!this.thumbnailCache) {+ this.thumbnailCache = await CacheStorageService.open(+ CACHES.THUMBS+ );+ }+ return this.thumbnailCache;} catch (e) {return null;// ignore}}- public async getCachedThumbnail(- file: EnteFile,- thumbnailCache?: LimitedCache- ) {+ public async getCachedThumbnail(file: EnteFile) {try {- if (!thumbnailCache) {- thumbnailCache = await this.getThumbnailCache();- }+ const thumbnailCache = await this.getThumbnailCache();const cacheResp: Response = await thumbnailCache?.match(file.id.toString());@@ -83,10 +82,7 @@ class DownloadManager {if (!this.thumbnailObjectURLPromise.has(file.id)) {const downloadPromise = async () => {const thumbnailCache = await this.getThumbnailCache();- const cachedThumb = await this.getCachedThumbnail(- file,- thumbnailCache- );+ const cachedThumb = await this.getCachedThumbnail(file);if (cachedThumb) {return cachedThumb;}