Factor out channel config handler

This commit is contained in:
Dominik Werder
2022-02-28 13:55:34 +01:00
parent 36ecc858fd
commit f82989f5c9
14 changed files with 248 additions and 83 deletions

View File

@@ -321,10 +321,20 @@ pub async fn read_local_config(channel: Channel, node: Node) -> Result<Config, E
.join(&channel.name)
.join("latest")
.join("00000_Config");
// TODO use commonio here to wrap the error conversion
let buf = match tokio::fs::read(&path).await {
Ok(k) => k,
Err(e) => match e.kind() {
ErrorKind::NotFound => return Err(Error::with_msg(format!("ErrorKind::NotFound for {:?}", path))),
ErrorKind::NotFound => {
return Err(Error::with_public_msg(format!(
"databuffer channel config file not found for channel {channel:?} at {path:?}"
)))
}
ErrorKind::PermissionDenied => {
return Err(Error::with_public_msg(format!(
"databuffer channel config file permission denied for channel {channel:?} at {path:?}"
)))
}
_ => return Err(e.into()),
},
};