Closed shawaj closed 3 years ago
Yes, it'd be good to fix this. You've found the right function - use path.exists()
to check which variant exists.
Thanks @kornelski I'll have a go!
@kornelski not sure if I have done this right, but it builds...
fn try_parse<P: AsRef<Path>>(path: P) -> CDResult<Option<Self>> {
if path.as_ref().join(".cargo/config").exists() {
let path = path.as_ref().join(".cargo/config");
if !path.exists() {
return Ok(None);
}
Ok(Some(Self::from_str(&fs::read_to_string(&path)?, path)?))
} else {
let path = path.as_ref().join(".cargo/config.toml");
if !path.exists() {
return Ok(None);
}
Ok(Some(Self::from_str(&fs::read_to_string(&path)?, path)?))
}
}
Maybe this bit in the first if
is redundant?
if !path.exists() {
return Ok(None);
}
As per the docs here the preferred config is
.config/config.toml
instead of.config/config
but due to the code here:https://github.com/mmstick/cargo-deb/blob/b5e4f398545a42ecbfdae7175f47c09cde103655/src/config.rs#L38
It is only looking at
.config/config
Happy to make some updates and PR if you could point me in the right direction?