mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-24 22:56:26 -08:00
i think i might have been stupid
This commit is contained in:
parent
31f95ea41d
commit
0621f55c20
|
@ -86,11 +86,11 @@ export class Client {
|
||||||
console.log(`Chunk length ${chunk.byteLength}`)
|
console.log(`Chunk length ${chunk.byteLength}`)
|
||||||
while (position < chunk.byteLength) {
|
while (position < chunk.byteLength) {
|
||||||
let capture = Math.min(
|
let capture = Math.min(
|
||||||
this.config.maxDiscordFileSize - (bytes_sent % this.config.maxDiscordFileSize),
|
this.config.maxDiscordFileSize - (bytes_sent % this.config.maxDiscordFileSize) + 1,
|
||||||
chunk.byteLength
|
chunk.byteLength
|
||||||
)
|
)
|
||||||
console.log(`Capturing ${capture} bytes, ${chunk.subarray(position, capture).byteLength}`)
|
console.log(`Capturing ${capture} bytes, ${chunk.subarray(position, position+capture).byteLength}`)
|
||||||
stream.push( chunk.subarray(position, capture) )
|
stream.push( chunk.subarray(position, position + capture) )
|
||||||
position += capture, bytes_sent += capture
|
position += capture, bytes_sent += capture
|
||||||
|
|
||||||
console.log("Chunk progress:", bytes_sent % this.config.maxDiscordFileSize, "B")
|
console.log("Chunk progress:", bytes_sent % this.config.maxDiscordFileSize, "B")
|
||||||
|
|
|
@ -136,14 +136,18 @@ export class UploadStream extends Writable {
|
||||||
|
|
||||||
while (progress < data.byteLength) {
|
while (progress < data.byteLength) {
|
||||||
let capture = Math.min(
|
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
|
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()
|
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`);
|
console.log(`pushed ${data.byteLength} byte chunk`);
|
||||||
progress += capture, this.filled += capture
|
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()
|
callback()
|
||||||
|
|
Loading…
Reference in a new issue