webcord: fix loading with broken config
This commit is contained in:
		
							parent
							
								
									a45a6dcfd4
								
							
						
					
					
						commit
						009e179ce4
					
				
					 2 changed files with 17 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -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;
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										14
									
								
								patches/webcord/fix-reading-config.patch
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								patches/webcord/fix-reading-config.patch
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -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<T> {
 | 
			
		||||
   #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);
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue