diff options
Diffstat (limited to 'src/cmd/count.rs')
-rw-r--r-- | src/cmd/count.rs | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/src/cmd/count.rs b/src/cmd/count.rs deleted file mode 100644 index 5de542b..0000000 --- a/src/cmd/count.rs +++ /dev/null @@ -1,27 +0,0 @@ -use std::path::PathBuf; - -use protobuf::Message; - -use crate::cmd::open_submaildir; -use crate::error::Result; -use crate::pb3::jwebmail::{StatsReq, StatsResp}; - -pub fn count(path: PathBuf, req: &[u8]) -> Result<Vec<u8>> { - let r = StatsReq::parse_from_bytes(req)?; - - let md = open_submaildir(path, &r.folder); - - let mut resp = StatsResp::new(); - resp.mail_count = md.count_cur() as u32; - resp.unread_count = md - .list_cur() - .filter(|x| x.as_ref().map_or(false, |z| !z.is_seen())) - .count() as u32; - resp.byte_size = md - .path() - .join("cur") - .read_dir()? - .map(|x| x.map_or(0, |z| z.metadata().map_or(0, |y| y.len()))) - .sum(); - resp.write_to_bytes().map_err(|e| e.into()) -} |