diff options
Diffstat (limited to 'src/cmd/folders.rs')
-rw-r--r-- | src/cmd/folders.rs | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/cmd/folders.rs b/src/cmd/folders.rs index b6f7209..b50daa9 100644 --- a/src/cmd/folders.rs +++ b/src/cmd/folders.rs @@ -1,26 +1,24 @@ use std::collections::BTreeSet; use std::ffi::{OsStr, OsString}; use std::path::{Path, PathBuf}; -use std::sync::OnceLock; +use std::sync::LazyLock; use protobuf::Message as _; use crate::error::Result; use crate::pb3::jwebmail::{FoldersReq, FoldersResp}; -static REQUIRED_MAILDIR_DIRS: OnceLock<BTreeSet<OsString>> = OnceLock::new(); +static REQUIRED_MAILDIR_DIRS: LazyLock<BTreeSet<OsString>> = LazyLock::new(|| { + [ + OsString::from("cur"), + "new".into(), + "tmp".into(), + "maildirfolder".into(), + ] + .into() +}); 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('.')) @@ -32,7 +30,7 @@ fn is_mailsubdir(p: &Path) -> bool { .and_then(|dir_entry| dir_entry.path().file_name().map(OsStr::to_owned)) }) .collect::<BTreeSet<_>>() - .is_superset(rmd) + .is_superset(&*REQUIRED_MAILDIR_DIRS) }) .unwrap_or_default() } |