webcord: fix loading with broken config
This commit is contained in:
		
							parent
							
								
									a45a6dcfd4
								
							
						
					
					
						commit
						009e179ce4
					
				
					 2 changed files with 17 additions and 1 deletions
				
			
		
							
								
								
									
										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