|
@@ -19,6 +19,7 @@ import { PhotosDownloadClient } from './clients/photos';
|
|
import { PublicAlbumsDownloadClient } from './clients/publicAlbums';
|
|
import { PublicAlbumsDownloadClient } from './clients/publicAlbums';
|
|
import isElectron from 'is-electron';
|
|
import isElectron from 'is-electron';
|
|
import { isInternalUser } from 'utils/user';
|
|
import { isInternalUser } from 'utils/user';
|
|
|
|
+import { Events, eventBus } from '@ente/shared/events';
|
|
|
|
|
|
export type LivePhotoSourceURL = {
|
|
export type LivePhotoSourceURL = {
|
|
image: () => Promise<string>;
|
|
image: () => Promise<string>;
|
|
@@ -89,12 +90,30 @@ class DownloadManagerImpl {
|
|
this.diskFileCache = isElectron() && (await openDiskFileCache());
|
|
this.diskFileCache = isElectron() && (await openDiskFileCache());
|
|
this.cryptoWorker = await ComlinkCryptoWorker.getInstance();
|
|
this.cryptoWorker = await ComlinkCryptoWorker.getInstance();
|
|
this.ready = true;
|
|
this.ready = true;
|
|
|
|
+ eventBus.on(Events.LOGOUT, this.logoutHandler.bind(this), this);
|
|
} catch (e) {
|
|
} catch (e) {
|
|
logError(e, 'DownloadManager init failed');
|
|
logError(e, 'DownloadManager init failed');
|
|
throw e;
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private async logoutHandler() {
|
|
|
|
+ try {
|
|
|
|
+ addLogLine('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 = () => {};
|
|
|
|
+ addLogLine('downloadManager logoutHandler completed');
|
|
|
|
+ } catch (e) {
|
|
|
|
+ logError(e, 'downloadManager logoutHandler failed');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
updateToken(token: string, passwordToken?: string) {
|
|
updateToken(token: string, passwordToken?: string) {
|
|
this.downloadClient.updateTokens(token, passwordToken);
|
|
this.downloadClient.updateTokens(token, passwordToken);
|
|
}
|
|
}
|