diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-01-12 13:46:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-12 23:46:36 +1100 |
commit | 6122374e4d97b2db040e8a98e4187dd0a0bccf9e (patch) | |
tree | 6748fddf0ebd5477d797003122a8ae9adb156004 /src/util | |
parent | Temp fix for DMs (diff) | |
download | server-6122374e4d97b2db040e8a98e4187dd0a0bccf9e.tar.xz |
Dev/post refactor fixes (#927)
* Re-introduce outgoing message logging Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com> * Websocket dumping * Sentry user count on API * Generate session ID upon opening websocket, fix gateway dumps * Async file io in src/gateway/events/Message.ts Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com> * Async file io in src/util/util/Config.ts Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com> * Make pre-commit hook executable Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com> * Fixed sync file io in src/util/util/Config.ts Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com> * Fixed missing await call in src/util/util/AutoUpdate.ts Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com> * Add comment to src/gateway/events/Connection.ts Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com> * Clean up gateway dumping code Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com> Co-authored-by: Madeline <46743919+MaddyUnderStars@users.noreply.github.com>
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/util/AutoUpdate.ts | 2 | ||||
-rw-r--r-- | src/util/util/Config.ts | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/util/util/AutoUpdate.ts b/src/util/util/AutoUpdate.ts index 769d959f..6fbad63e 100644 --- a/src/util/util/AutoUpdate.ts +++ b/src/util/util/AutoUpdate.ts @@ -60,7 +60,7 @@ async function download(url: string, dir: string) { const response = await fetch(url, { agent }); const buffer = await response.buffer(); const tempDir = await fs.mkdtemp("fosscord"); - fs.writeFile(path.join(tempDir, "Fosscord.zip"), buffer); + await fs.writeFile(path.join(tempDir, "Fosscord.zip"), buffer); } catch (error) { console.error(`[Auto Update] download failed`, error); } diff --git a/src/util/util/Config.ts b/src/util/util/Config.ts index 5d98f5bc..149f3746 100644 --- a/src/util/util/Config.ts +++ b/src/util/util/Config.ts @@ -1,5 +1,6 @@ import { ConfigEntity } from "../entities/Config"; -import fs from "fs"; +import fs from "fs/promises"; +import syncFs from "fs"; import { ConfigValue } from "../config"; // TODO: yaml instead of json @@ -31,11 +32,14 @@ export const Config = { ); try { const overrideConfig = JSON.parse( - fs.readFileSync(overridePath, { encoding: "utf8" }), + await fs.readFile(overridePath, { encoding: "utf8" }), ); config = overrideConfig.merge(config); } catch (error) { - fs.writeFileSync(overridePath, JSON.stringify(config, null, 4)); + await fs.writeFile( + overridePath, + JSON.stringify(config, null, 4), + ); } } @@ -79,7 +83,7 @@ function applyConfig(val: ConfigValue) { } if (process.env.CONFIG_PATH) - fs.writeFileSync(overridePath, JSON.stringify(val, null, 4)); + syncFs.writeFileSync(overridePath, JSON.stringify(val, null, 4)); return apply(val); } |