浏览代码

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>
Manos Pitsidianakis 7 月之前
父节点
当前提交
12de82e7
共有 1 个文件被更改,包括 22 次插入0 次删除
  1. 22 0
      melib/src/conf.rs

+ 22 - 0
melib/src/conf.rs

@@ -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(())
     }