diff options
Diffstat (limited to 'src/cmd/folders.rs')
-rw-r--r-- | src/cmd/folders.rs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/cmd/folders.rs b/src/cmd/folders.rs index 7bf93f1..0133528 100644 --- a/src/cmd/folders.rs +++ b/src/cmd/folders.rs @@ -1,23 +1,25 @@ use std::collections::BTreeSet; use std::ffi::{OsStr, OsString}; use std::path::Path; +use std::sync::OnceLock; -use lazy_static::lazy_static; use maildir::Maildir; use crate::error::Result; -lazy_static! { - static ref REQUIRED_MAILDIR_DIRS: BTreeSet<OsString> = [ - OsString::from("cur"), - "new".into(), - "tmp".into(), - "maildirfolder".into(), - ] - .into(); -} +static REQUIRED_MAILDIR_DIRS: OnceLock<BTreeSet<OsString>> = OnceLock::new(); fn is_mailsubdir(p: &Path) -> bool { + let rmd = REQUIRED_MAILDIR_DIRS.get_or_init(|| { + [ + OsString::from("cur"), + "new".into(), + "tmp".into(), + "maildirfolder".into(), + ] + .into() + }); + p.is_dir() && p.file_name() .map_or(false, |fname| fname.to_string_lossy().starts_with('.')) @@ -29,7 +31,7 @@ fn is_mailsubdir(p: &Path) -> bool { .and_then(|dir_entry| dir_entry.path().file_name().map(OsStr::to_owned)) }) .collect::<BTreeSet<_>>() - .is_superset(&REQUIRED_MAILDIR_DIRS) + .is_superset(rmd) }) .unwrap_or_default() } |