mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 19:52:14 -08:00
Added failsafe to configuration loading.
If file is malformed or corrupt, generate a fresh configuration file.
This commit is contained in:
parent
1566ff4e4c
commit
4f416220c2
@ -101,10 +101,23 @@ exports.load = function(){
|
|||||||
config = DEFAULT_CONFIG
|
config = DEFAULT_CONFIG
|
||||||
exports.save()
|
exports.save()
|
||||||
} else {
|
} else {
|
||||||
|
let doValidate = false
|
||||||
|
try {
|
||||||
config = JSON.parse(fs.readFileSync(filePath, 'UTF-8'))
|
config = JSON.parse(fs.readFileSync(filePath, 'UTF-8'))
|
||||||
|
doValidate = true
|
||||||
|
} catch (err){
|
||||||
|
console.error(err)
|
||||||
|
console.log('%c[ConfigManager]', 'color: #a02d2a; font-weight: bold', 'Configuration file contains malformed JSON or is corrupt.')
|
||||||
|
console.log('%c[ConfigManager]', 'color: #a02d2a; font-weight: bold', 'Generating a new configuration file.')
|
||||||
|
mkpath.sync(path.join(filePath, '..'))
|
||||||
|
config = DEFAULT_CONFIG
|
||||||
|
exports.save()
|
||||||
|
}
|
||||||
|
if(doValidate){
|
||||||
config = validateKeySet(DEFAULT_CONFIG, config)
|
config = validateKeySet(DEFAULT_CONFIG, config)
|
||||||
exports.save()
|
exports.save()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
console.log('%c[ConfigManager]', 'color: #a02d2a; font-weight: bold', 'Successfully Loaded')
|
console.log('%c[ConfigManager]', 'color: #a02d2a; font-weight: bold', 'Successfully Loaded')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,6 +361,9 @@ const settingsCurrentAccounts = document.getElementById('settingsCurrentAccounts
|
|||||||
function populateAuthAccounts(){
|
function populateAuthAccounts(){
|
||||||
const authAccounts = ConfigManager.getAuthAccounts()
|
const authAccounts = ConfigManager.getAuthAccounts()
|
||||||
const authKeys = Object.keys(authAccounts)
|
const authKeys = Object.keys(authAccounts)
|
||||||
|
if(authKeys.length === 0){
|
||||||
|
return
|
||||||
|
}
|
||||||
const selectedUUID = ConfigManager.getSelectedAccount().uuid
|
const selectedUUID = ConfigManager.getSelectedAccount().uuid
|
||||||
|
|
||||||
let authAccountStr = ''
|
let authAccountStr = ''
|
||||||
@ -1112,8 +1115,10 @@ function populateSettingsUpdateInformation(data){
|
|||||||
settingsUpdateChangelogCont.style.display = 'none'
|
settingsUpdateChangelogCont.style.display = 'none'
|
||||||
populateVersionInformation(remote.app.getVersion(), settingsUpdateVersionValue, settingsUpdateVersionTitle, settingsUpdateVersionCheck)
|
populateVersionInformation(remote.app.getVersion(), settingsUpdateVersionValue, settingsUpdateVersionTitle, settingsUpdateVersionCheck)
|
||||||
settingsUpdateButtonStatus('Check for Updates', false, () => {
|
settingsUpdateButtonStatus('Check for Updates', false, () => {
|
||||||
|
if(!isDev){
|
||||||
ipcRenderer.send('autoUpdateAction', 'checkForUpdate')
|
ipcRenderer.send('autoUpdateAction', 'checkForUpdate')
|
||||||
settingsUpdateButtonStatus('Checking for Updates..', true)
|
settingsUpdateButtonStatus('Checking for Updates..', true)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user