From 009e179ce4d67fee26d81c354679f9c657bf9351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Eug=C3=AAnio?= Date: Sat, 18 Feb 2023 22:15:01 -0300 Subject: [PATCH] webcord: fix loading with broken config --- overlays/default.nix | 4 +++- patches/webcord/fix-reading-config.patch | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 patches/webcord/fix-reading-config.patch diff --git a/overlays/default.nix b/overlays/default.nix index 3133381..3993d6c 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -45,7 +45,9 @@ mpvpaper = inputs.wegank.packages.${prev.system}.mpvpaper; sea-orm-cli = inputs.sea-orm-cli.legacyPackages.${prev.system}.sea-orm-cli; - webcord = prev.webcord or prev.unstable.webcord; + webcord = (prev.webcord or prev.unstable.webcord).overrideAttrs (old: { + patches = (old.patches or [ ]) ++ [ ../patches/webcord/fix-reading-config.patch ]; + }); nil-lsp = inputs.nil-lsp.packages.${prev.system}.nil; }); diff --git a/patches/webcord/fix-reading-config.patch b/patches/webcord/fix-reading-config.patch new file mode 100644 index 0000000..92e89ca --- /dev/null +++ b/patches/webcord/fix-reading-config.patch @@ -0,0 +1,14 @@ +diff --git a/sources/code/main/modules/config.ts b/sources/code/main/modules/config.ts +index caf51df..41faabe 100644 +--- a/sources/code/main/modules/config.ts ++++ b/sources/code/main/modules/config.ts +@@ -158,6 +158,9 @@ class Config { + #read(): unknown { + const encodedData = readFileSync(this.#path+this.#pathExtension); + let decodedData = encodedData.toString(); ++ if (decodedData === "") ++ return {}; ++ + if(this.#pathExtension === FileExt.Encrypted) + decodedData = safeStorage.decryptString(encodedData); + return JSON.parse(decodedData);