mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-10-31 12:03:39 +00:00 
			
		
		
		
	config-files: Move all the configuration files into config folder. (#508)
This commit moves all the configuration(.json) files into a config folder if the config folder doesn't already exist. It also updates the places where these files are being accessed with the new address. This will help us zip the folder easily in the future.
This commit is contained in:
		
				
					committed by
					
						 Akash Nimare
						Akash Nimare
					
				
			
			
				
	
			
			
			
						parent
						
							eeb0b4a666
						
					
				
				
					commit
					df35ffc3b0
				
			| @@ -11,6 +11,7 @@ if (process.type === 'renderer') { | ||||
| const zulipDir = app.getPath('userData'); | ||||
| const logDir = `${zulipDir}/Logs/`; | ||||
| const certificatesDir = `${zulipDir}/certificates/`; | ||||
| const configDir = `${zulipDir}/config/`; | ||||
| const initSetUp = () => { | ||||
| 	// if it is the first time the app is running | ||||
| 	// create zulip dir in userData folder to | ||||
| @@ -28,6 +29,46 @@ const initSetUp = () => { | ||||
| 			fs.mkdirSync(certificatesDir); | ||||
| 		} | ||||
|  | ||||
| 		// Migrate config files from app data folder to config folder inside app | ||||
| 		// data folder. This will be done once when a user updates to the new version. | ||||
| 		if (!fs.existsSync(configDir)) { | ||||
| 			fs.mkdirSync(configDir); | ||||
| 			const domainJson = `${zulipDir}/domain.json`; | ||||
| 			const certificatesJson = `${zulipDir}/certificates.json`; | ||||
| 			const settingsJson = `${zulipDir}/settings.json`; | ||||
| 			const updatesJson = `${zulipDir}/updates.json`; | ||||
| 			const windowStateJson = `${zulipDir}/window-state.json`; | ||||
| 			const configData = [ | ||||
| 				{ | ||||
| 					path: domainJson, | ||||
| 					fileName: `domain.json` | ||||
| 				}, | ||||
| 				{ | ||||
| 					path: certificatesJson, | ||||
| 					fileName: `certificates.json` | ||||
| 				}, | ||||
| 				{ | ||||
| 					path: settingsJson, | ||||
| 					fileName: `settings.json` | ||||
| 				}, | ||||
| 				{ | ||||
| 					path: updatesJson, | ||||
| 					fileName: `updates.json` | ||||
| 				} | ||||
| 			]; | ||||
| 			configData.forEach(data => { | ||||
| 				if (fs.existsSync(data.path)) { | ||||
| 					fs.copyFileSync(data.path, configDir + data.fileName); | ||||
| 					fs.unlinkSync(data.path); | ||||
| 				} | ||||
| 			}); | ||||
| 			// window-state.json is only deleted not moved, as the electron-window-state | ||||
| 			// package will recreate the file in the config folder. | ||||
| 			if (fs.existsSync(windowStateJson)) { | ||||
| 				fs.unlinkSync(windowStateJson); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		setupCompleted = true; | ||||
| 	} | ||||
| }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user