changelog, add json5

This commit is contained in:
2021-10-12 00:20:42 +02:00
parent 4ddc26c6ca
commit 6ff0e3653d
7 changed files with 84 additions and 9 deletions
+5 -5
View File
@@ -163,7 +163,7 @@ async fn load_or_create_control_file(control_path: impl AsRef<Path>) -> Result<M
let mut dirty = false;
let mut control: MutableConfig = if control_path.is_file() {
let f = tokio::fs::read(&control_path).await?;
let mut control: MutableConfig = serde_json::from_slice(&f)?;
let mut control: MutableConfig = json5::from_str(&String::from_utf8_lossy(&f))?;
control._path = control_path.to_owned();
control
} else {
@@ -185,7 +185,7 @@ async fn load_or_create_state_file(state_path: impl AsRef<Path>) -> Result<State
let mut dirty = false;
let mut state: StateConfig = if state_path.is_file() {
let f = tokio::fs::read(&state_path).await?;
let mut control: StateConfig = serde_json::from_slice(&f)?;
let mut control: StateConfig = json5::from_str(&String::from_utf8_lossy(&f))?;
control._path = state_path.to_owned();
control
} else {
@@ -206,7 +206,7 @@ async fn load_locale_override_file(locale_path: impl AsRef<Path>) -> Result<Opti
let locale_path = locale_path.as_ref();
if locale_path.is_file() {
let f = tokio::fs::read(&locale_path).await?;
let opt : TranslationTable = serde_json::from_slice(&f)?;
let opt : TranslationTable = json5::from_str(&String::from_utf8_lossy(&f))?;
Ok(Some(opt))
} else {
Ok(None)
@@ -275,7 +275,7 @@ impl GroupConfig {
let mut dirty = false;
let mut config: FixedConfig = if config_path.is_file() {
let f = tokio::fs::read(&config_path).await?;
let mut config: FixedConfig = serde_json::from_slice(&f)?;
let mut config: FixedConfig = json5::from_str(&String::from_utf8_lossy(&f))?;
config._path = config_path;
if config.appdata != appdata {
config.appdata = appdata;
@@ -321,7 +321,7 @@ impl GroupConfig {
/* config */
let f = tokio::fs::read(&config_path).await?;
let mut config: FixedConfig = serde_json::from_slice(&f)?;
let mut config: FixedConfig = json5::from_str(&String::from_utf8_lossy(&f))?;
config._path = config_path;
/* control */
+2 -2
View File
@@ -71,7 +71,7 @@ impl ConfigStore {
let config: CommonConfig = if let Some(cf) = &common_file {
debug!("Loading common config from {}", cf.display());
let f = tokio::fs::read(&cf).await?;
serde_json::from_slice(&f)?
json5::from_str(&String::from_utf8_lossy(&f))?
} else {
debug!("No common config file, using defaults");
CommonConfig::default()
@@ -225,7 +225,7 @@ impl ConfigStore {
}
fn load_locale(&mut self, locale_name: &str, locale_json: &str, is_default: bool) {
if let Ok(mut tr) = serde_json::from_str::<TranslationTable>(locale_json) {
if let Ok(mut tr) = json5::from_str::<TranslationTable>(locale_json) {
debug!("Loaded locale: {}", locale_name);
if !is_default {