fix: conf error (#295)

This commit is contained in:
lencx
2023-02-03 01:11:56 +08:00
parent 93bb98e9c0
commit 041ffb7462
2 changed files with 17 additions and 5 deletions

View File

@@ -76,7 +76,14 @@ impl AppConf {
pub fn read() -> Self {
match std::fs::read_to_string(Self::file_path()) {
Ok(v) => serde_json::from_str::<AppConf>(&v).unwrap(),
Ok(v) => {
if let Ok(v2) = serde_json::from_str::<AppConf>(&v) {
v2
} else {
error!("conf_read_parse_error");
Self::default()
}
}
Err(err) => {
error!("conf_read_error: {}", err);
Self::default()