Skip to content

Commit a559001

Browse files
committed
config: ensure configured mail_dir exists
This is a small protection against typos in this config item. Its possible that you actually wanted a subdir of the notmuch mail_root, but typed it wrong. That would lead notmuch to miscompute the notmuch path prefix, which could result in mujmap having the wrong idea about what mail exists locally or on the server, with a risk of mail being deleted from one or both ends. Its hard to say what the odds are of a mistyped path matching a valid directory, but it seems reasonably unlikely, so hopefully this will prevent the most common case.
1 parent bba235c commit a559001

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ pub enum Error {
4646
#[snafu(display("Could not decode password command output as utf-8"))]
4747
DecodePasswordCommand { source: FromUtf8Error },
4848

49+
#[snafu(display("`mail_dir' path is not a directory: {}", path.to_string_lossy()))]
50+
MailDirPathNotDirectory { path: PathBuf },
51+
4952
#[snafu(display("`cache_dir' path must be absolute: {}", path.to_string_lossy()))]
5053
CacheDirPathNotAbsolute { path: PathBuf },
5154
#[snafu(display("`mail_dir' path must be absolute: {}", path.to_string_lossy()))]
@@ -318,6 +321,8 @@ impl Config {
318321
if cpath.is_dir() {
319322
if config.mail_dir.is_none() {
320323
config.mail_dir = Some(cpath.clone());
324+
} else {
325+
ensure!(path.is_dir(), MailDirPathNotDirectorySnafu { path });
321326
}
322327
if config.state_dir.is_none() {
323328
config.state_dir = Some(cpath.clone());

0 commit comments

Comments
 (0)