mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-21 21:36:26 -08:00
files update on get
This commit is contained in:
parent
2ebc50a312
commit
6dc6b12b91
|
@ -299,6 +299,10 @@ export default class Files {
|
|||
|
||||
let attachments: Discord.Attachment[] = [];
|
||||
|
||||
/* File updates */
|
||||
let file_updates: Pick<FilePointer, "chunkSize" | "sizeInBytes"> = {}
|
||||
let atSIB: number[] = [] // kepes track of the size of each file...
|
||||
|
||||
for (let xi = scan_msg_begin; xi < scan_msg_end+1; xi++) {
|
||||
|
||||
let msg = await this.uploadChannel.messages.fetch(file.messageids[xi]).catch(() => {return null})
|
||||
|
@ -308,6 +312,7 @@ export default class Files {
|
|||
for (let i = (useRanges && xi == scan_msg_begin ? ( scan_files_begin - (xi*10) ) : 0); i < (useRanges && xi == scan_msg_end ? ( scan_files_end - (xi*10) + 1 ) : attach.length); i++) {
|
||||
|
||||
attachments.push(attach[i])
|
||||
atSIB.push(attach[i].size)
|
||||
|
||||
}
|
||||
|
||||
|
@ -315,6 +320,24 @@ export default class Files {
|
|||
|
||||
}
|
||||
|
||||
if (!file.sizeInBytes) file_updates.sizeInBytes = atSIB.reduce((a,b) => a+b);
|
||||
if (!file.chunkSize) file_updates.chunkSize = atSIB[0]
|
||||
if (Object.keys(file_updates).length) { // if file_updates not empty
|
||||
// i gotta do these weird workarounds, ts is weird sometimes
|
||||
// originally i was gonna do key is keyof FilePointer but for some reason
|
||||
// it ended up making typeof file[key] never??? so
|
||||
// its 10pm and chinese people suck at being quiet so i just wanna get this over with
|
||||
// chinese is the worst language in terms of volume lmao
|
||||
let valid_fp_keys = ["sizeInBytes", "chunkSize"]
|
||||
let isValidFilePointerKey = (key: string): key is "sizeInBytes" | "chunkSize" => valid_fp_keys.includes(key)
|
||||
|
||||
for (let [key,value] of Object.entries(file_updates)) {
|
||||
if (isValidFilePointerKey(key)) file[key] = value
|
||||
}
|
||||
|
||||
writeFile(process.cwd()+"/.data/files.json",JSON.stringify(this.files),(err) => {})
|
||||
}
|
||||
|
||||
let position = 0;
|
||||
|
||||
let getNextChunk = async () => {
|
||||
|
|
Loading…
Reference in a new issue