i think i might have been stupid

This commit is contained in:
May 2024-03-01 11:30:12 -08:00 committed by GitHub
parent 31f95ea41d
commit 0621f55c20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View file

@ -86,11 +86,11 @@ export class Client {
console.log(`Chunk length ${chunk.byteLength}`)
while (position < chunk.byteLength) {
let capture = Math.min(
this.config.maxDiscordFileSize - (bytes_sent % this.config.maxDiscordFileSize),
this.config.maxDiscordFileSize - (bytes_sent % this.config.maxDiscordFileSize) + 1,
chunk.byteLength
)
console.log(`Capturing ${capture} bytes, ${chunk.subarray(position, capture).byteLength}`)
stream.push( chunk.subarray(position, capture) )
console.log(`Capturing ${capture} bytes, ${chunk.subarray(position, position+capture).byteLength}`)
stream.push( chunk.subarray(position, position + capture) )
position += capture, bytes_sent += capture
console.log("Chunk progress:", bytes_sent % this.config.maxDiscordFileSize, "B")

View file

@ -136,14 +136,18 @@ export class UploadStream extends Writable {
while (progress < data.byteLength) {
let capture = Math.min(
this.config.maxDiscordFileSize - (this.filled % this.config.maxDiscordFileSize),
(this.config.maxDiscordFileSize*10) - (this.filled % (this.config.maxDiscordFileSize*10)) + 1,
chunk.byteLength
)
console.log(`Capturing ${capture} bytes, ${chunk.subarray(position, capture).byteLength}`)
console.log(`Capturing ${capture} bytes, ${chunk.subarray(position, position + capture).byteLength}`)
let nextStream = await this.getNextStream()
nextStream.push( chunk.subarray(position, capture) )
nextStream.push( chunk.subarray(position, position+capture) )
console.log(`pushed ${data.byteLength} byte chunk`);
progress += capture, this.filled += capture
// message is full, so tell the next run to get a new message
if (this.filled % (this.config.maxDiscordFileSize*10) == 0)
this.current = undefined
}
callback()