From 0dcb367cc823a0910dc194b1f38e843f885032e3 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Wed, 11 Dec 2019 22:20:43 -0500 Subject: [PATCH 1/2] fixes an issue with account name in cacc being set to command invoker --- src/commands/createaccount.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/createaccount.ts b/src/commands/createaccount.ts index aff9360..69ae920 100644 --- a/src/commands/createaccount.ts +++ b/src/commands/createaccount.ts @@ -40,7 +40,7 @@ export default class CreateAccount extends Command { const tempPass = this.client.util.randomPassword(); let passHash = await this.client.util.createHash(tempPass); passHash = passHash.replace(/[$]/g, '\\$').replace('\n', ''); - const acctName = message.author.username.replace(/[!@#$%^&*(),.?":{}|<>]/g, '-').replace(/\s/g, '-'); + const acctName = this.client.users.get(args[0]).username.replace(/[!@#$%^&*(),.?":{}|<>]/g, '-').replace(/\s/g, '-'); const etcPasswd = `${acctName},${args[0]},,`; await this.client.util.createAccount(passHash, etcPasswd, args[2], args[0], args[1], message.author.id); From cb097067b5b1123a07c357abc89c5824ee09f321 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Fri, 13 Dec 2019 19:23:48 -0500 Subject: [PATCH 2/2] fix for disk blocking --- src/intervals/storage.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/intervals/storage.ts b/src/intervals/storage.ts index 939edf4..b499888 100644 --- a/src/intervals/storage.ts +++ b/src/intervals/storage.ts @@ -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();