This commit is contained in:
Manav Rathi 2024-05-15 13:29:09 +05:30
parent 585c0a8285
commit 1648229f4c
No known key found for this signature in database
2 changed files with 20 additions and 21 deletions

View file

@ -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) {

View file

@ -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);
}
}