not failing on invalid p2p files

This commit is contained in:
mrfry 2023-04-08 18:19:12 +02:00
parent e46fed69c3
commit dbe6272240
4 changed files with 20 additions and 5 deletions

View file

@ -435,15 +435,29 @@ function setup(data: SubmoduleData): Submodule {
fname: paths.peersFile,
logMsg: 'Peers file updated',
action: () => {
peers = utils.ReadJSON(paths.peersFile)
try {
peers = utils.ReadJSON(paths.peersFile)
} catch (e) {
logger.Log(
`Peers file contents are invalid! Check if syntax is correct for ${paths.peersFile}`,
'redbg'
)
}
},
},
{
fname: paths.selfInfoFile,
logMsg: 'P2P self info file changed',
action: () => {
selfInfo = utils.ReadJSON(paths.selfInfoFile)
selfInfo.publicKey = publicKey
try {
selfInfo = utils.ReadJSON(paths.selfInfoFile)
selfInfo.publicKey = publicKey
} catch (e) {
logger.Log(
`Self info file contents are invalid! Check if syntax is correct for ${paths.selfInfoFile}`,
'redbg'
)
}
},
},
]