Manav Rathi 2024-04-13 06:56:46 +05:30
parent 3499e47c88
commit b5096b02da
No known key found for this signature in database
3 changed files with 3 additions and 19 deletions

View file

@ -10,14 +10,11 @@ export class PhotosDownloadClient implements DownloadClient {
private token: string,
private timeout: number,
) {}
updateTokens(token: string) {
this.token = token;
}
updateTimeout(timeout: number) {
this.timeout = timeout;
}
async downloadThumbnail(file: EnteFile): Promise<Uint8Array> {
if (!this.token) {
throw Error(CustomError.TOKEN_MISSING);

View file

@ -20,10 +20,6 @@ export class PublicAlbumsDownloadClient implements DownloadClient {
this.passwordToken = passwordToken;
}
updateTimeout(timeout: number) {
this.timeout = timeout;
}
downloadThumbnail = async (file: EnteFile) => {
if (!this.token) {
throw Error(CustomError.TOKEN_MISSING);

View file

@ -40,7 +40,6 @@ export type OnDownloadProgress = (event: {
export interface DownloadClient {
updateTokens: (token: string, passwordToken?: string) => void;
updateTimeout: (timeout: number) => void;
downloadThumbnail: (
file: EnteFile,
timeout?: number,
@ -77,13 +76,12 @@ class DownloadManagerImpl {
async init(
app: APPS,
tokens?: { token: string; passwordToken?: string } | { token: string },
timeout?: number,
) {
if (this.ready) {
log.info("DownloadManager already initialized");
return;
}
this.downloadClient = createDownloadClient(app, tokens, timeout);
this.downloadClient = createDownloadClient(app, tokens);
try {
this.thumbnailCache = await openCache("thumbs");
} catch (e) {
@ -127,10 +125,6 @@ class DownloadManagerImpl {
this.cryptoWorker = cryptoWorker;
}
updateTimeout(timeout: number) {
this.downloadClient.updateTimeout(timeout);
}
setProgressUpdater(progressUpdater: (value: Map<number, number>) => void) {
this.progressUpdater = progressUpdater;
}
@ -525,11 +519,8 @@ export default DownloadManager;
function createDownloadClient(
app: APPS,
tokens?: { token: string; passwordToken?: string } | { token: string },
timeout?: number,
): DownloadClient {
if (!timeout) {
timeout = 300000; // 5 minute
}
const timeout = 300000; // 5 minute
if (app === APPS.ALBUMS) {
if (!tokens) {
tokens = { token: undefined, passwordToken: undefined };