don't hold 2x stream size while reassembling
This commit is contained in:
@@ -145,12 +145,14 @@ async function assemble(streamId: string, total: number) {
|
|||||||
// check at each step the chunk names (ranges) are coherent
|
// check at each step the chunk names (ranges) are coherent
|
||||||
let written = 0;
|
let written = 0;
|
||||||
while (written < total) {
|
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;
|
if (!part) break;
|
||||||
const file = await part.getFile();
|
const file = await part.getFile();
|
||||||
if (!file.size) break;
|
if (!file.size) break;
|
||||||
await writable.write(file);
|
await writable.write(file);
|
||||||
written += file.size;
|
written += file.size;
|
||||||
|
await dir.removeEntry(name).catch(() => {});
|
||||||
}
|
}
|
||||||
await writable.close();
|
await writable.close();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user