Skip to content

armgit / ente

Public Imported from GitHub
0

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

Cleanup

Manav Rathie8c2717bf7bf
diff --git a/web/apps/photos/src/services/download/index.ts b/web/apps/photos/src/services/download/index.ts
index e931bf872e..7163c22085 100644
--- a/web/apps/photos/src/services/download/index.ts
+++ b/web/apps/photos/src/services/download/index.ts
@@ -361,9 +361,14 @@ class DownloadManagerImpl {
buffer.set(new Uint8Array(data), 0);
buffer.set(new Uint8Array(value), data.byteLength);
+ // Note that buffer.length might be a multiple of
+ // decryptionChunkSizes. We let that accumulate, and
+ // drain it all with a while loop when done.
+
if (buffer.length > decryptionChunkSize) {
- const fileData = new Uint8Array(
- buffer.slice(0, decryptionChunkSize),
+ const fileData = buffer.slice(
+ 0,
+ decryptionChunkSize,
);
const { decryptedData } =
@@ -372,11 +377,9 @@ class DownloadManagerImpl {
pullState,
);
controller.enqueue(decryptedData);
- data = new Uint8Array(
- buffer.slice(decryptionChunkSize),
- );
+ data = buffer.slice(decryptionChunkSize);
} else {
- data = new Uint8Array(buffer);
+ data = buffer;
}
more = true;
} else {