don't hold 2x stream size while reassembling

This commit is contained in:
2026-09-02 20:51:58 +02:00
parent 828c0a1d7b
commit 0ed1a094a2
+3 -1
View File
@@ -145,12 +145,14 @@ async function assemble(streamId: string, total: number) {
// check at each step the chunk names (ranges) are coherent
let written = 0;
while (written < total) {
const part = await dir.getFileHandle(String(written)).catch(() => null);
const name = String(written);
const part = await dir.getFileHandle(name).catch(() => null);
if (!part) break;
const file = await part.getFile();
if (!file.size) break;
await writable.write(file);
written += file.size;
await dir.removeEntry(name).catch(() => {});
}
await writable.close();