From 56cda63c83897e09c36f7650718c23bb951837ff Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Thu, 14 Nov 2019 17:49:40 +0200 Subject: [PATCH] Fix some warnings --- melib/src/backends/imap/connection.rs | 30 +++++++++++++++---------- melib/src/backends/imap/watch.rs | 11 ++++++--- melib/src/email/parser.rs | 2 +- melib/src/parsec.rs | 23 ------------------- ui/src/cache.rs | 2 +- ui/src/components/mail/listing/plain.rs | 22 +++++++++--------- 6 files changed, 39 insertions(+), 51 deletions(-) diff --git a/melib/src/backends/imap/connection.rs b/melib/src/backends/imap/connection.rs index 7904f67d7..c2993f41f 100644 --- a/melib/src/backends/imap/connection.rs +++ b/melib/src/backends/imap/connection.rs @@ -375,18 +375,24 @@ impl From for ImapBlockingConnection { fn from(mut conn: ImapConnection) -> Self { conn.set_nonblocking(false) .expect("set_nonblocking call failed"); - conn.stream.as_mut().map(|s| { - s.stream - .get_mut() - .set_write_timeout(Some(std::time::Duration::new(5 * 60, 0))) - .expect("set_write_timeout call failed") - }); - conn.stream.as_mut().map(|s| { - s.stream - .get_mut() - .set_read_timeout(Some(std::time::Duration::new(5 * 60, 0))) - .expect("set_read_timeout call failed") - }); + conn.stream + .as_mut() + .map(|s| { + s.stream + .get_mut() + .set_write_timeout(Some(std::time::Duration::new(5 * 60, 0))) + .expect("set_write_timeout call failed") + }) + .expect("set_write_timeout call failed"); + conn.stream + .as_mut() + .map(|s| { + s.stream + .get_mut() + .set_read_timeout(Some(std::time::Duration::new(5 * 60, 0))) + .expect("set_read_timeout call failed") + }) + .expect("set_read_timeout call failed"); ImapBlockingConnection { buf: [0; 1024], conn, diff --git a/melib/src/backends/imap/watch.rs b/melib/src/backends/imap/watch.rs index 71e190162..c4a4afa26 100644 --- a/melib/src/backends/imap/watch.rs +++ b/melib/src/backends/imap/watch.rs @@ -86,7 +86,6 @@ pub fn poll_with_examine(kit: ImapWatchKit) -> Result<()> { main_conn.send_command(b"NOOP").unwrap(); main_conn.read_response(&mut response).unwrap(); } - Ok(()) } pub fn idle(kit: ImapWatchKit) -> Result<()> { @@ -208,7 +207,7 @@ pub fn idle(kit: ImapWatchKit) -> Result<()> { if now.duration_since(watch) >= _5_mins { /* Time to poll all inboxes */ let mut conn = main_conn.lock().unwrap(); - for (hash, folder) in folders.lock().unwrap().iter() { + for folder in folders.lock().unwrap().values() { work_context .set_status .send(( @@ -216,7 +215,13 @@ pub fn idle(kit: ImapWatchKit) -> Result<()> { format!("examining `{}` for updates...", folder.path()), )) .unwrap(); - examine_updates(folder, &sender, &mut conn, &uid_store, &work_context); + exit_on_error!( + sender, + folder_hash, + work_context, + thread_id, + examine_updates(folder, &sender, &mut conn, &uid_store, &work_context) + ); } work_context .set_status diff --git a/melib/src/email/parser.rs b/melib/src/email/parser.rs index 3ccc1c467..747ac747d 100644 --- a/melib/src/email/parser.rs +++ b/melib/src/email/parser.rs @@ -467,7 +467,7 @@ fn display_addr(input: &[u8]) -> IResult<&[u8], Address> { match phrase(&input[0..end + display_name.length + 3]) { IResult::Error(e) => IResult::Error(e), IResult::Incomplete(i) => IResult::Incomplete(i), - IResult::Done(rest, raw) => { + IResult::Done(_, raw) => { let display_name_end = raw.find(b"<").unwrap(); display_name.length = { raw[0..display_name_end].trim().len() }; let address_spec = if display_name_end == 0 { diff --git a/melib/src/parsec.rs b/melib/src/parsec.rs index 97328a68a..a447ed543 100644 --- a/melib/src/parsec.rs +++ b/melib/src/parsec.rs @@ -19,8 +19,6 @@ * along with meli. If not, see . */ -use crate::structs::StackVec; - pub type Result<'a, Output> = std::result::Result<(&'a str, Output), &'a str>; pub trait Parser<'a, Output> { @@ -54,16 +52,6 @@ pub trait Parser<'a, Output> { { BoxedParser::new(and_then(self, f)) } - - fn seq(self, p: P) -> BoxedParser<'a, NewOutput> - where - Self: Sized + 'a, - Output: 'a, - NewOutput: 'a, - P: Parser<'a, NewOutput> + 'a, - { - BoxedParser::new(seq(self, p)) - } } pub fn left<'a, P1, P2, R1, R2>(parser1: P1, parser2: P2) -> impl Parser<'a, R1> @@ -321,14 +309,3 @@ where Err(_) => Ok((input, None)), } } - -pub fn seq<'a, P1, P2, R1, R2>(parser1: P1, parser2: P2) -> impl Parser<'a, R2> -where - P1: Parser<'a, R1>, - P2: Parser<'a, R2>, -{ - move |input| match parser1.parse(input) { - Ok((next_input, result)) => parser2.parse(next_input), - Err(e) => Err(e), - } -} diff --git a/ui/src/cache.rs b/ui/src/cache.rs index b63327970..f0e7530f2 100644 --- a/ui/src/cache.rs +++ b/ui/src/cache.rs @@ -419,7 +419,7 @@ pub fn query_to_imap(q: &Query) -> String { pub fn imap_search( term: &str, - (sort_field, sort_order): (SortField, SortOrder), + (_sort_field, _sort_order): (SortField, SortOrder), folder_hash: FolderHash, backend: &Arc>>, ) -> Result> { diff --git a/ui/src/components/mail/listing/plain.rs b/ui/src/components/mail/listing/plain.rs index 92dd6b5c8..3491fde2c 100644 --- a/ui/src/components/mail/listing/plain.rs +++ b/ui/src/components/mail/listing/plain.rs @@ -522,12 +522,14 @@ impl PlainListing { return; } } - let envelopes = context.accounts[self.cursor_pos.0] - .collection + self.local_collection = context.accounts[self.cursor_pos.0][folder_hash] + .unwrap() .envelopes - .read() - .unwrap(); - self.local_collection = envelopes.keys().cloned().collect(); + .iter() + .cloned() + .collect(); + self.redraw_list(context); + if self.length > 0 { let env_hash = self.get_env_under_cursor(self.cursor_pos.2, context); let temp = (self.new_cursor_pos.0, self.new_cursor_pos.1, env_hash); @@ -537,8 +539,6 @@ impl PlainListing { self.view = MailView::new(temp, None, None); } } - - self.redraw_list(context); } fn redraw_list(&mut self, context: &Context) { @@ -765,9 +765,7 @@ impl PlainListing { } } - fn get_env_under_cursor(&self, cursor: usize, context: &Context) -> EnvelopeHash { - let account = &context.accounts[self.cursor_pos.0]; - let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash(); + fn get_env_under_cursor(&self, cursor: usize, _context: &Context) -> EnvelopeHash { if self.filter_term.is_empty() { self.local_collection[cursor] } else { @@ -993,7 +991,9 @@ impl Component for PlainListing { UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => { let account = &context.accounts[self.cursor_pos.0]; let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash(); - if !account.collection.contains_key(new_hash) { + if !account.collection.contains_key(new_hash) + || !account[folder_hash].unwrap().envelopes.contains(new_hash) + { return false; }