fix for disk blocking

merge-requests/1/merge
Matthew 2019-12-13 19:23:48 -05:00
parent 0838022eae
commit cb097067b5
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 12 additions and 10 deletions

View File

@ -6,16 +6,18 @@ export default async function storage(client: Client) {
const main = async () => {
const accounts = await client.db.Account.find();
for (const account of accounts) {
const res = await client.util.exec(`du -bs /home/${account.username}`);
let bytes = Number(res.split('/')[0].replace('\t', ''));
try {
await fs.access(`/var/mail/${account.username}`, fs.constants.F_OK);
const res2 = await client.util.exec(`du -bs /var/mail/${account.username}`);
bytes += Number(res2.split('/')[0].replace('\t', ''));
} catch {
bytes += 0;
}
await client.redis.set(`storage-${account.username}`, bytes);
setTimeout(async () => {
const res = await client.util.exec(`du -bs /home/${account.username}`);
let bytes = Number(res.split('/')[0].replace('\t', ''));
try {
await fs.access(`/var/mail/${account.username}`, fs.constants.F_OK);
const res2 = await client.util.exec(`du -bs /var/mail/${account.username}`);
bytes += Number(res2.split('/')[0].replace('\t', ''));
} catch {
bytes += 0;
}
await client.redis.set(`storage-${account.username}`, bytes);
}, 600000);
}
};
await main();