From e0e8116c1857d8f66462eff7673bfcc6d0143627 Mon Sep 17 00:00:00 2001 From: Anomalocaridid <29845794+Anomalocaridid@users.noreply.github.com> Date: Fri, 27 Dec 2024 01:49:20 +0000 Subject: [PATCH] vesktop: fix crashing when settings.json or state.json are read-only (#368221) --- .../ve/vesktop/fix_read_only_settings.patch | 19 +++++++++++++++++++ pkgs/by-name/ve/vesktop/package.nix | 5 ++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 pkgs/by-name/ve/vesktop/fix_read_only_settings.patch diff --git a/pkgs/by-name/ve/vesktop/fix_read_only_settings.patch b/pkgs/by-name/ve/vesktop/fix_read_only_settings.patch new file mode 100644 index 0000000000000..f36a7e9280995 --- /dev/null +++ b/pkgs/by-name/ve/vesktop/fix_read_only_settings.patch @@ -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(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; diff --git a/pkgs/by-name/ve/vesktop/package.nix b/pkgs/by-name/ve/vesktop/package.nix index 0eb1d43b13188..db812da65fe26 100644 --- a/pkgs/by-name/ve/vesktop/package.nix +++ b/pkgs/by-name/ve/vesktop/package.nix @@ -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;