summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd/folders.rs24
-rw-r--r--src/cmd/list.rs2
2 files changed, 14 insertions, 12 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()
}
diff --git a/src/cmd/list.rs b/src/cmd/list.rs
index 0ec0389..b77a311 100644
--- a/src/cmd/list.rs
+++ b/src/cmd/list.rs
@@ -24,7 +24,7 @@ fn mid_to_rec_time(mid: &str) -> f64 {
warn!("Invaild mail-id {}", mid);
return 0.0;
};
- let Some(sep) = mid[dec+1..].find('.') else {
+ let Some(sep) = mid[dec + 1..].find('.') else {
return 0.0;
};
mid[..dec + 1 + sep].parse().unwrap()