1
0
Fork 0

fix issue with storage

refactor/models
Matthew 2019-11-09 23:23:26 -05:00
parent b924e08ced
commit e40d8fe47f
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 3 additions and 2 deletions

View File

@ -6,10 +6,11 @@ export default function storage(client: Client) {
const main = async () => {
const accounts = await client.db.Account.find();
for (const account of accounts) {
let bytes = Number(await client.util.exec(`du -bs /home/${account.username}`));
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);
bytes += Number(await client.util.exec(`du -bs /var/mail/${account.username}`));
bytes += Number(res.split('/')[0].replace('\t', ''));
} catch {
bytes += 0;
}