Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Tweak

Manav Rathi8ae7565542ce
diff --git a/web/packages/new/photos/services/download.ts b/web/packages/new/photos/services/download.ts
index dded588030..1717d6863a 100644
--- a/web/packages/new/photos/services/download.ts
+++ b/web/packages/new/photos/services/download.ts
@@ -349,12 +349,6 @@ class DownloadManagerImpl {
): Promise<ReadableStream<Uint8Array> | null> {
log.info(`download attempted for file id ${file.id}`);
- const onDownloadProgress = this.trackDownloadProgress(
- file.id,
- // TODO: Is info supposed to be optional though?
- file.info?.fileSize ?? 0,
- );
-
const res = await this._downloadFile(file);
if (
@@ -362,7 +356,6 @@ class DownloadManagerImpl {
file.metadata.fileType === FileType.livePhoto
) {
const encryptedData = new Uint8Array(await res.arrayBuffer());
- this.clearDownloadProgress(file.id);
const decrypted = await decryptStreamBytes(
{
@@ -378,6 +371,12 @@ class DownloadManagerImpl {
if (!body) return null;
const reader = body.getReader();
+ const onDownloadProgress = this.trackDownloadProgress(
+ file.id,
+ // TODO: Is info supposed to be optional though?
+ file.info?.fileSize ?? 0,
+ );
+
const contentLength =
parseInt(res.headers.get("Content-Length") ?? "") || 0;
let downloadedBytes = 0;
@@ -480,12 +479,6 @@ class DownloadManagerImpl {
this.setFileDownloadProgress(progress);
};
}
-
- private clearDownloadProgress(fileID: number) {
- const progress = new Map(this.fileDownloadProgress);
- progress.delete(fileID);
- this.setFileDownloadProgress(progress);
- }
}
const DownloadManager = new DownloadManagerImpl();