vesktop: fix crashing when settings.json or state.json are read-only (#368221)

This commit is contained in:
Anomalocaridid 2024-12-27 01:49:20 +00:00 committed by GitHub
parent 3eecbac9c5
commit e0e8116c18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 1 deletions

View File

@ -0,0 +1,19 @@
diff --git a/src/main/settings.ts b/src/main/settings.ts
index 6fad97f..dfc64e3 100644
--- a/src/main/settings.ts
+++ b/src/main/settings.ts
@@ -26,8 +26,12 @@ function loadSettings<T extends object = any>(file: string, name: string) {
const store = new SettingsStore(settings);
store.addGlobalChangeListener(o => {
- mkdirSync(dirname(file), { recursive: true });
- writeFileSync(file, JSON.stringify(o, null, 4));
+ try {
+ mkdirSync(dirname(file), { recursive: true });
+ writeFileSync(file, JSON.stringify(o, null, 4));
+ } catch (e) {
+ console.error("Nix: Failed to write settings.", e);
+ }
});
return store;

View File

@ -69,7 +69,10 @@ stdenv.mkDerivation (finalAttrs: {
];
patches =
[ ./disable_update_checking.patch ]
[
./disable_update_checking.patch
./fix_read_only_settings.patch
]
++ lib.optional withSystemVencord (
replaceVars ./use_system_vencord.patch {
inherit vencord;