From 1648229f4c22ed5297d050a05ddbbd9a2afaf8e1 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Wed, 15 May 2024 13:29:09 +0530 Subject: [PATCH] Download --- .../photos/src/services/download/index.ts | 26 +++++++------------ web/apps/photos/src/services/logout.ts | 15 ++++++++--- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/web/apps/photos/src/services/download/index.ts b/web/apps/photos/src/services/download/index.ts index a148f2bcf..0618cd0e6 100644 --- a/web/apps/photos/src/services/download/index.ts +++ b/web/apps/photos/src/services/download/index.ts @@ -6,7 +6,6 @@ import { APPS } from "@ente/shared/apps/constants"; import ComlinkCryptoWorker from "@ente/shared/crypto"; import { DedicatedCryptoWorker } from "@ente/shared/crypto/internal/crypto.worker"; import { CustomError } from "@ente/shared/error"; -import { Events, eventBus } from "@ente/shared/events"; import { isPlaybackPossible } from "@ente/shared/media/video-playback"; import { Remote } from "comlink"; import isElectron from "is-electron"; @@ -107,7 +106,6 @@ class DownloadManagerImpl { // } this.cryptoWorker = await ComlinkCryptoWorker.getInstance(); this.ready = true; - eventBus.on(Events.LOGOUT, this.logoutHandler.bind(this), this); } private ensureInitialized() { @@ -117,21 +115,15 @@ class DownloadManagerImpl { ); } - private async logoutHandler() { - try { - log.info("downloadManger logoutHandler started"); - this.ready = false; - this.cryptoWorker = null; - this.downloadClient = null; - this.fileObjectURLPromises.clear(); - this.fileConversionPromises.clear(); - this.thumbnailObjectURLPromises.clear(); - this.fileDownloadProgress.clear(); - this.progressUpdater = () => {}; - log.info("downloadManager logoutHandler completed"); - } catch (e) { - log.error("downloadManager logoutHandler failed", e); - } + async logout() { + this.ready = false; + this.cryptoWorker = null; + this.downloadClient = null; + this.fileObjectURLPromises.clear(); + this.fileConversionPromises.clear(); + this.thumbnailObjectURLPromises.clear(); + this.fileDownloadProgress.clear(); + this.progressUpdater = () => {}; } updateToken(token: string, passwordToken?: string) { diff --git a/web/apps/photos/src/services/logout.ts b/web/apps/photos/src/services/logout.ts index e9ba49597..73db5cf3f 100644 --- a/web/apps/photos/src/services/logout.ts +++ b/web/apps/photos/src/services/logout.ts @@ -2,6 +2,7 @@ import log from "@/next/log"; import { accountLogout } from "@ente/accounts/services/logout"; import { Events, eventBus } from "@ente/shared/events"; import { clipService } from "services/clip-service"; +import DownloadManager from "./download"; import exportService from "./export"; import mlWorkManager from "./machineLearning/mlWorkManager"; @@ -15,10 +16,16 @@ import mlWorkManager from "./machineLearning/mlWorkManager"; export const photosLogout = async () => { await accountLogout(); + try { + await DownloadManager.logout(); + } catch (e) { + log.error("Ignoring error during logout (download)", e); + } + try { await clipService.logout(); } catch (e) { - log.error("Ignoring error in CLIP logout", e); + log.error("Ignoring error during logout (CLIP)", e); } const electron = globalThis.electron; @@ -26,19 +33,19 @@ export const photosLogout = async () => { try { await mlWorkManager.setMlSearchEnabled(false); } catch (e) { - log.error("Ignoring error in ML logout", e); + log.error("Ignoring error during logout (ML)", e); } try { exportService.disableContinuousExport(); } catch (e) { - log.error("Ignoring error when export logout", e); + log.error("Ignoring error during logout (export)", e); } try { await electron?.logout(); } catch (e) { - log.error("Ignoring error in native side logout sequence", e); + log.error("Ignoring error during logout (electron)", e); } }