diff --git a/server/src/file/mod.rs b/server/src/file/mod.rs index 4aeba0c..f4a92f8 100644 --- a/server/src/file/mod.rs +++ b/server/src/file/mod.rs @@ -37,10 +37,16 @@ pub trait DataFile: Default + Serialize + DeserializeOwned { } let mut f = fs::File::open(from).await?; - let mut buf = Vec::new(); - f.read_to_end(&mut buf).await?; + let mut buf = String::new(); + f.read_to_string(&mut buf).await?; - Ok(serde_json::from_slice(&buf)?) + // Remove comments, e.g. 'Ansible Managed' + let buf = buf + .lines() + .filter(|v| !v.starts_with("#")) + .collect::(); + + Ok(serde_json::from_str(&buf)?) } async fn try_write_new>(to: P) -> Result<(), DataFileError> { diff --git a/server/src/server/types/authorization.rs b/server/src/server/types/authorization.rs index 878f02d..ff6cc5a 100644 --- a/server/src/server/types/authorization.rs +++ b/server/src/server/types/authorization.rs @@ -41,11 +41,9 @@ impl FromRequest for Authorization { return if Self::ADMIN { Err(AuthorizationError::NoToken) } else { - Ok(Self { - is_admin: false, - }) + Ok(Self { is_admin: false }) } - }, + } }; let config: &WConfig = req.app_data().unwrap(); @@ -65,20 +63,16 @@ impl FromRequest for Authorization { if Self::ADMIN { Err(AuthorizationError::NoToken) } else { - Ok(Self { - is_admin: false, - }) + Ok(Self { is_admin: false }) } - }, + } _ => { if Self::ADMIN { Err(AuthorizationError::Koala) } else { - Ok(Self { - is_admin: false, - }) + Ok(Self { is_admin: false }) } - }, + } } } };