Fix dir size checking

This commit is contained in:
Essem 2022-07-19 21:28:52 -05:00
parent 93fa8e8098
commit 809f659f3d
No known key found for this signature in database
GPG Key ID: 7D497397CC3A2A8C
1 changed files with 1 additions and 2 deletions

View File

@ -34,7 +34,6 @@ export async function upload(client, result, context, interaction = false) {
}));
}
if (process.env.THRESHOLD) {
process.env.DIRSIZECACHE += result.file.length;
await removeOldImages();
}
}
@ -53,7 +52,7 @@ export async function removeOldImages() {
}).filter(Boolean);
const resolvedFiles = await Promise.all(files);
process.env.DIRSIZECACHE = resolvedFiles.reduce((a, b)=>{
return a + b.size;
return a.size + b.size;
}, 0);
const oldestFiles = resolvedFiles.sort((a, b) => a.ctime - b.ctime);
while (process.env.DIRSIZECACHE > process.env.THRESHOLD) {