From ee906d59e48c6d9e8006cc2d22695d2a358fa6be Mon Sep 17 00:00:00 2001 From: smartfrigde <37928912+smartfrigde@users.noreply.github.com> Date: Sun, 28 Jan 2024 16:02:04 +0100 Subject: [PATCH] seperate corruption checks --- src/utils.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 0b49fc0..2fef7cf 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -30,18 +30,23 @@ export async function checkIfConfigIsBroken(): Promise { let settingsData = fs.readFileSync(getConfigLocation(), "utf-8"); JSON.parse(settingsData); console.log("Config is fine"); + } catch (e) { + console.error(e); + console.log("Detected a corrupted config"); + setup(); + dialog.showErrorBox( + "Oops, something went wrong.", + "ArmCord has detected that your configuration file is corrupted, please restart the app and set your settings again. If this issue persists, report it on the support server/Github issues." + ); + } + try { let windowData = fs.readFileSync(getWindowStateLocation(), "utf-8"); JSON.parse(windowData); console.log("Window config is fine"); } catch (e) { console.error(e); - console.log("Detected a corrupted config"); - setup(); fs.writeFileSync(getWindowStateLocation(), "{}", "utf-8"); - dialog.showErrorBox( - "Oops, something went wrong.", - "ArmCord has detected that your configuration file is corrupted, please restart the app and set your settings again. If this issue persists, report it on the support server/Github issues." - ); + console.log("Detected a corrupted window config"); } }