mirror of
https://github.com/mollersuite/monofile.git
synced 2024-10-06 20:16:25 -07: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 */
|
/* File updates */
|
||||||
let file_updates: Pick<FilePointer, "chunkSize" | "sizeInBytes"> =
|
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
|
let msg = await this.api
|
||||||
.fetchMessage(file.messageids[xi])
|
.fetchMessage(file.messageids[msgIdx])
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
|
|
||||||
if (msg?.attachments) {
|
if (msg?.attachments) {
|
||||||
let attach = Array.from(msg.attachments.values())
|
let attach = Array.from(msg.attachments.values())
|
||||||
for (
|
for (
|
||||||
let i =
|
let i =
|
||||||
|
|
||||||
useRanges && xi == scan_msg_begin
|
useRanges && msgIdx == scan_msg_begin
|
||||||
? scan_files_begin - xi * 10
|
? scan_files_begin - msgIdx * 10
|
||||||
: 0;
|
: 0;
|
||||||
i <
|
i <
|
||||||
(useRanges && xi == scan_msg_end
|
(useRanges && msgIdx == scan_msg_end
|
||||||
? scan_files_end - xi * 10 + 1
|
? scan_files_end - msgIdx * 10 + 1
|
||||||
: attach.length);
|
: attach.length);
|
||||||
i++
|
i++
|
||||||
) {
|
) {
|
||||||
|
@ -375,6 +381,9 @@ export default class Files {
|
||||||
atSIB.push(attach[i].size)
|
atSIB.push(attach[i].size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msgIdx++
|
||||||
|
return attachments.splice(0,1)[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file.sizeInBytes)
|
if (!file.sizeInBytes)
|
||||||
|
@ -408,7 +417,7 @@ export default class Files {
|
||||||
let position = 0
|
let position = 0
|
||||||
|
|
||||||
let getNextChunk = async () => {
|
let getNextChunk = async () => {
|
||||||
let scanning_chunk = attachments[position]
|
let scanning_chunk = await getNextAttachment()
|
||||||
if (!scanning_chunk) {
|
if (!scanning_chunk) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue