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

authored by Anomalocaridid and committed by GitHub e0e8116c 3eecbac9

+23 -1
+19
pkgs/by-name/ve/vesktop/fix_read_only_settings.patch
··· 1 + diff --git a/src/main/settings.ts b/src/main/settings.ts 2 + index 6fad97f..dfc64e3 100644 3 + --- a/src/main/settings.ts 4 + +++ b/src/main/settings.ts 5 + @@ -26,8 +26,12 @@ function loadSettings<T extends object = any>(file: string, name: string) { 6 + 7 + const store = new SettingsStore(settings); 8 + store.addGlobalChangeListener(o => { 9 + - mkdirSync(dirname(file), { recursive: true }); 10 + - writeFileSync(file, JSON.stringify(o, null, 4)); 11 + + try { 12 + + mkdirSync(dirname(file), { recursive: true }); 13 + + writeFileSync(file, JSON.stringify(o, null, 4)); 14 + + } catch (e) { 15 + + console.error("Nix: Failed to write settings.", e); 16 + + } 17 + }); 18 + 19 + return store;
+4 -1
pkgs/by-name/ve/vesktop/package.nix
··· 69 69 ]; 70 70 71 71 patches = 72 - [ ./disable_update_checking.patch ] 72 + [ 73 + ./disable_update_checking.patch 74 + ./fix_read_only_settings.patch 75 + ] 73 76 ++ lib.optional withSystemVencord ( 74 77 replaceVars ./use_system_vencord.patch { 75 78 inherit vencord;