melib/conf: fix mutt_alias_file not being validated
`mutt_alias_file` was not removed from the `extras` field of `AccountSettings` in the `validate_config` function, thus if you used it in your account configuration you'd get an error: 'Configuration error: Unrecognised configuration values: {"mutt_alias_file": "<value>"}' Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
This commit is contained in:
parent
192ecea2a4
commit
12de82e7b4
1 changed files with 22 additions and 0 deletions
|
@ -153,6 +153,28 @@ impl AccountSettings {
|
|||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
if let Some(mutt_alias_file) = self.extra.swap_remove("mutt_alias_file") {
|
||||
let path = Path::new(&mutt_alias_file).expand();
|
||||
|
||||
if !matches!(path.try_exists(), Ok(true)) {
|
||||
return Err(Error::new(format!(
|
||||
"`mutt_alias_file` path {} does not exist",
|
||||
path.display()
|
||||
))
|
||||
.set_details("`mutt_alias_file` must be an existing path of a mutt alias file")
|
||||
.set_kind(ErrorKind::Configuration));
|
||||
}
|
||||
if !path.is_file() {
|
||||
return Err(Error::new(format!(
|
||||
"`mutt_alias_file` path {} is not a file",
|
||||
path.display()
|
||||
))
|
||||
.set_details("`mutt_alias_file` must be a path of a mutt alias file")
|
||||
.set_kind(ErrorKind::Configuration));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue