mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-21 21:36:26 -08:00
i think that this should work well enough
This commit is contained in:
parent
460df7164a
commit
f3e9f58ea4
|
@ -349,25 +349,31 @@ export default class Files {
|
|||
/* File updates */
|
||||
let file_updates: Pick<FilePointer, "chunkSize" | "sizeInBytes"> =
|
||||
{}
|
||||
let atSIB: number[] = [] // kepes track of the size of each file...
|
||||
let atSIB: number[] = [] // keeps track of the size of each file...
|
||||
|
||||
let msgIdx = scan_msg_begin
|
||||
|
||||
let getNextAttachment = async () => {
|
||||
let ret = attachments.splice(0,1)[0]
|
||||
if (ret) return ret
|
||||
|
||||
for (let xi = scan_msg_begin; xi < scan_msg_end + 1; xi++) {
|
||||
let msg = await this.api
|
||||
.fetchMessage(file.messageids[xi])
|
||||
.fetchMessage(file.messageids[msgIdx])
|
||||
.catch(() => {
|
||||
return null
|
||||
})
|
||||
|
||||
if (msg?.attachments) {
|
||||
let attach = Array.from(msg.attachments.values())
|
||||
for (
|
||||
let i =
|
||||
|
||||
useRanges && xi == scan_msg_begin
|
||||
? scan_files_begin - xi * 10
|
||||
useRanges && msgIdx == scan_msg_begin
|
||||
? scan_files_begin - msgIdx * 10
|
||||
: 0;
|
||||
i <
|
||||
(useRanges && xi == scan_msg_end
|
||||
? scan_files_end - xi * 10 + 1
|
||||
(useRanges && msgIdx == scan_msg_end
|
||||
? scan_files_end - msgIdx * 10 + 1
|
||||
: attach.length);
|
||||
i++
|
||||
) {
|
||||
|
@ -375,6 +381,9 @@ export default class Files {
|
|||
atSIB.push(attach[i].size)
|
||||
}
|
||||
}
|
||||
|
||||
msgIdx++
|
||||
return attachments.splice(0,1)[0]
|
||||
}
|
||||
|
||||
if (!file.sizeInBytes)
|
||||
|
@ -408,7 +417,7 @@ export default class Files {
|
|||
let position = 0
|
||||
|
||||
let getNextChunk = async () => {
|
||||
let scanning_chunk = attachments[position]
|
||||
let scanning_chunk = await getNextAttachment()
|
||||
if (!scanning_chunk) {
|
||||
return null
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue