Skip to content

armgit / ente

Public Imported from GitHub
0

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

More asserts

Manav Rathi99d25e4bb5b7
diff --git a/web/packages/gallery/services/upload/upload-service.ts b/web/packages/gallery/services/upload/upload-service.ts
index 4abf8df0e2..628fcae463 100644
--- a/web/packages/gallery/services/upload/upload-service.ts
+++ b/web/packages/gallery/services/upload/upload-service.ts
@@ -1548,9 +1548,16 @@ const encryptFileStream = async (
const ref = { pullCount: 1 };
const encryptedFileStream = new ReadableStream({
async pull(controller) {
- const { value } = await fileStreamReader.read();
+ const { value, done } = await fileStreamReader.read();
+ if (done) {
+ // TransformStream in readUploadItem guarantees that we'll get
+ // encryption sized `chunkCount` chunks. Below we close the
+ // controller on the last chunk. So we shouldn't be getting a
+ // `done` here.
+ controller.close();
+ throw new Error("Unexpected stream state");
+ }
const encryptedFileChunk = await worker.encryptStreamChunk(
- // @ts-ignore
value,
pushState,
ref.pullCount === chunkCount,