This commit is contained in:
May 2023-06-28 23:22:26 -07:00
parent aaa1d64f1f
commit 0b72a64b84

View file

@ -346,9 +346,13 @@ export default class Files {
} }
let ord:number[] = [] let ord:number[] = []
// hopefully this regulates it?
let lastChunkSent = true
let dataStream = new Readable({ let dataStream = new Readable({
read(){ read(){
if (!lastChunkSent) return
lastChunkSent = false
console.log(`${uploadId}: Getting chunk ${position+1}/${attachments.length}`) console.log(`${uploadId}: Getting chunk ${position+1}/${attachments.length}`)
let gC = position+1 let gC = position+1
getNextChunk().then(async (nextChunk) => { getNextChunk().then(async (nextChunk) => {
@ -357,11 +361,17 @@ export default class Files {
if (nextChunk == "__ERR") {this.destroy(new Error("file read error")); return} if (nextChunk == "__ERR") {this.destroy(new Error("file read error")); return}
let response = this.push(nextChunk) let response = this.push(nextChunk)
if (!nextChunk) return // EOF
while (response) { while (response) {
console.log(`${uploadId}: Getting chunk ${position+1}/${attachments.length}`)
let nextChunk = await getNextChunk() let nextChunk = await getNextChunk()
let gC = position+1
ord.push(gC)
response = this.push(nextChunk) response = this.push(nextChunk)
if (!nextChunk) return if (!nextChunk) return
} }
lastChunkSent = true
}) })
} }
}) })