fix issue with storage

merge-requests/1/merge
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 main = async () => {
const accounts = await client.db.Account.find(); const accounts = await client.db.Account.find();
for (const account of accounts) { 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 { try {
await fs.access(`/var/mail/${account.username}`, fs.constants.F_OK); 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 { } catch {
bytes += 0; bytes += 0;
} }