mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-24 22:56:26 -08:00
Oh shit this doesn't respect backpressure
This commit is contained in:
parent
dcf35f80b3
commit
e92f5eaf6e
|
@ -234,6 +234,7 @@ export class UploadStream extends Writable {
|
||||||
|
|
||||||
await this.files.write()
|
await this.files.write()
|
||||||
delete this.files.locks[this.uploadId!]
|
delete this.files.locks[this.uploadId!]
|
||||||
|
if (this.owner) Accounts.files.index(this.owner, this.uploadId!)
|
||||||
return this.uploadId
|
return this.uploadId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,7 +470,7 @@ export default class Files {
|
||||||
if (ret) return ret
|
if (ret) return ret
|
||||||
|
|
||||||
// oh, there's none left. let's fetch a new message, then.
|
// oh, there's none left. let's fetch a new message, then.
|
||||||
if (!file.messageids[msgIdx] || msgIdx >= scan_msg_end) return null
|
if (!file.messageids[msgIdx] || msgIdx > scan_msg_end) return null
|
||||||
let msg = await this.api
|
let msg = await this.api
|
||||||
.fetchMessage(file.messageids[msgIdx])
|
.fetchMessage(file.messageids[msgIdx])
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
@ -478,14 +479,16 @@ export default class Files {
|
||||||
|
|
||||||
if (msg?.attachments) {
|
if (msg?.attachments) {
|
||||||
let attach = Array.from(msg.attachments.values())
|
let attach = Array.from(msg.attachments.values())
|
||||||
|
|
||||||
attachments = useRanges ? attach.slice(
|
attachments = useRanges ? attach.slice(
|
||||||
msgIdx == scan_msg_begin
|
msgIdx == scan_msg_begin
|
||||||
? scan_files_begin - msgIdx * 10
|
? scan_files_begin - scan_msg_begin * 10
|
||||||
: 0,
|
: 0,
|
||||||
msgIdx == scan_msg_end
|
msgIdx == scan_msg_end
|
||||||
? scan_files_end - msgIdx * 10 + 1
|
? scan_files_end - scan_msg_end * 10 + 1
|
||||||
: attach.length
|
: attach.length
|
||||||
) : attach
|
) : attach
|
||||||
|
console.log(attachments)
|
||||||
}
|
}
|
||||||
|
|
||||||
msgIdx++
|
msgIdx++
|
||||||
|
@ -541,7 +544,7 @@ export default class Files {
|
||||||
// oops, look like there's an error
|
// oops, look like there's an error
|
||||||
// or the stream has ended.
|
// or the stream has ended.
|
||||||
// let's destroy the stream
|
// let's destroy the stream
|
||||||
stream.destroy(next || undefined)
|
if (next) stream.destroy(next); else stream.push(null)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue