From 0b72a64b8407975fe120312b28b27820f7175c46 Mon Sep 17 00:00:00 2001 From: stringsplit <77242831+nbitzz@users.noreply.github.com> Date: Wed, 28 Jun 2023 23:22:26 -0700 Subject: [PATCH] attempt --- src/server/lib/files.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/server/lib/files.ts b/src/server/lib/files.ts index 7f12d74..ae66091 100644 --- a/src/server/lib/files.ts +++ b/src/server/lib/files.ts @@ -346,9 +346,13 @@ export default class Files { } let ord:number[] = [] + // hopefully this regulates it? + let lastChunkSent = true let dataStream = new Readable({ read(){ + if (!lastChunkSent) return + lastChunkSent = false console.log(`${uploadId}: Getting chunk ${position+1}/${attachments.length}`) let gC = position+1 getNextChunk().then(async (nextChunk) => { @@ -357,11 +361,17 @@ export default class Files { if (nextChunk == "__ERR") {this.destroy(new Error("file read error")); return} let response = this.push(nextChunk) + if (!nextChunk) return // EOF + while (response) { + console.log(`${uploadId}: Getting chunk ${position+1}/${attachments.length}`) let nextChunk = await getNextChunk() + let gC = position+1 + ord.push(gC) response = this.push(nextChunk) if (!nextChunk) return } + lastChunkSent = true }) } })