diff options
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/cmd.rs | 8 | ||||
-rw-r--r-- | src/cmd/move.rs | 12 | ||||
-rw-r--r-- | src/cmd/raw.rs | 5 | ||||
-rw-r--r-- | src/cmd/search.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 1 |
7 files changed, 23 insertions, 9 deletions
@@ -206,7 +206,7 @@ dependencies = [ [[package]] name = "jwebmail-extract" -version = "0.8.0" +version = "0.8.1" dependencies = [ "base64", "chrono", @@ -1,6 +1,6 @@ [package] name = "jwebmail-extract" -version = "0.8.0" +version = "0.8.1" authors = ["Jannis M. Hoffmann <jannis@fehcom.de>"] edition = "2021" rust-version = "1.80" @@ -11,9 +11,9 @@ mod list; mod r#move; mod raw; mod remove; +mod search; mod show; mod stats; -mod search; use add_folder::add_folder; use folders::folders; @@ -22,9 +22,9 @@ use list::list; use r#move::r#move; use raw::raw; use remove::remove; +use search::search; use show::show; use stats::stats; -use search::search; pub fn open_submaildir(mut path: PathBuf, sub: &str) -> Maildir { if !sub.is_empty() { @@ -39,7 +39,9 @@ pub struct MailStorage { impl Default for MailStorage { fn default() -> Self { - MailStorage { maildir_path: RwLock::new(None) } + MailStorage { + maildir_path: RwLock::new(None), + } } } diff --git a/src/cmd/move.rs b/src/cmd/move.rs index c852d6c..7fc762f 100644 --- a/src/cmd/move.rs +++ b/src/cmd/move.rs @@ -11,7 +11,17 @@ pub fn r#move( if let Some(p) = ms.maildir_path.read().unwrap().clone() { let from = open_submaildir(p.clone(), &from_folder); let to = open_submaildir(p, &to_folder); - from.move_to(&mid, &to).unwrap(); + if from.move_to(&mid, &to).is_err() { + // This is not neccessarily true! + // The error needs to be investigated to find out the actual cause. + // + // Other plausible causes: + // + // InvalidFolder(folder: from_folder) + // InvalidMid(folder: from_folder, mid: mid) + // + return call.reply_invalid_folder(to_folder); + } call.reply() } else { call.reply_not_initialized() diff --git a/src/cmd/raw.rs b/src/cmd/raw.rs index a20eded..0a4df86 100644 --- a/src/cmd/raw.rs +++ b/src/cmd/raw.rs @@ -36,6 +36,7 @@ pub fn raw( .map(|x| x.parse()) .collect::<std::result::Result<Vec<usize>, std::num::ParseIntError>>() { + let mut s; let mut m = mail.parsed().unwrap(); if path[0] != 0 { @@ -56,8 +57,8 @@ pub fn raw( mime_path.to_owned(), ); } - let s: &'static _ = m.get_body_raw().unwrap().leak(); - m = mailparse::parse_mail(s).unwrap(); + s = m.get_body_raw().unwrap(); + m = mailparse::parse_mail(&s).unwrap(); } x if x.starts_with("multipart/") => { if *i >= m.subparts.len() { diff --git a/src/cmd/search.rs b/src/cmd/search.rs index 7cf0fb0..00cc192 100644 --- a/src/cmd/search.rs +++ b/src/cmd/search.rs @@ -9,7 +9,7 @@ pub fn search( ) -> varlink::Result<()> { if let Some(p) = ms.maildir_path.read().unwrap().clone() { let md = open_submaildir(p, &folder); - + todo!(); } else { call.reply_not_initialized() diff --git a/src/main.rs b/src/main.rs index a8e33b2..5ab99e9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,6 +48,7 @@ fn main() { .split(':') .enumerate() .filter(|(_, name)| *name == "varlink") + .take(1) .for_each(|(i, _)| { accept_con(&service, unsafe { UnixStream::from_raw_fd(3 + i as i32) }) }); |