Skip to content

Commit

Permalink
vesktop: fix crashing when settings.json or state.json are read-only (#…
Browse files Browse the repository at this point in the history
…368221)

(cherry picked from commit e0e8116)
  • Loading branch information
Anomalocaridid authored and getchoo committed Dec 27, 2024
1 parent ca43778 commit 3e1db89
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
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;
14 changes: 9 additions & 5 deletions pkgs/by-name/ve/vesktop/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,15 @@ stdenv.mkDerivation (finalAttrs: {
];

patches =
[ ./disable_update_checking.patch ]
++ lib.optional withSystemVencord (substituteAll {
inherit vencord;
src = ./use_system_vencord.patch;
});
[
./disable_update_checking.patch
./fix_read_only_settings.patch
]
++ lib.optional withSystemVencord (
replaceVars ./use_system_vencord.patch {
inherit vencord;
}
);

env = {
ELECTRON_SKIP_BINARY_DOWNLOAD = 1;
Expand Down

0 comments on commit 3e1db89

Please sign in to comment.