Skip to content

Commit

Permalink
vesktop: fix crashing when settings.json or state.json are read-only (N…
Browse files Browse the repository at this point in the history
  • Loading branch information
Anomalocaridid authored Dec 27, 2024
1 parent 3eecbac commit e0e8116
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
19 changes: 19 additions & 0 deletions pkgs/by-name/ve/vesktop/fix_read_only_settings.patch
Original file line number Diff line number Diff line change
@@ -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;
5 changes: 4 additions & 1 deletion pkgs/by-name/ve/vesktop/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e0e8116

Please sign in to comment.