From 4e967280e17757488106b7489114dd0e76a53c96 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Mon, 26 Aug 2024 10:51:00 +0300 Subject: [PATCH] nntp: don't needlessly select group before ARTICLE GROUP was sent before ARTICLE every time even if the group was already selected. Use Connection's `select_group` method that makes sure the group is not re-selected needlessly. Signed-off-by: Manos Pitsidianakis --- melib/src/nntp/operations.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/melib/src/nntp/operations.rs b/melib/src/nntp/operations.rs index 76e031d4..cf830d5d 100644 --- a/melib/src/nntp/operations.rs +++ b/melib/src/nntp/operations.rs @@ -58,22 +58,14 @@ impl BackendOp for NntpOp { Ok(Box::pin(async move { let mut res = String::with_capacity(8 * 1024); let mut conn = connection.lock().await; - let path = uid_store.mailboxes.lock().await[&mailbox_hash] - .name() - .to_string(); - conn.send_command(format!("GROUP {}", path).as_bytes()) - .await?; - conn.read_response(&mut res, false, &["211 "]).await?; - if !res.starts_with("211 ") { - return Err(Error::new(format!( - "{} Could not select newsgroup {}: expected GROUP response but got: {}", - &uid_store.account_name, path, res - ))); - } + conn.select_group(mailbox_hash, false, &mut res).await?; conn.send_command(format!("ARTICLE {}", uid).as_bytes()) .await?; conn.read_response(&mut res, true, &["220 "]).await?; if !res.starts_with("220 ") { + let path = uid_store.mailboxes.lock().await[&mailbox_hash] + .name() + .to_string(); return Err(Error::new(format!( "{} Could not select article {}: expected ARTICLE response but got: {}", &uid_store.account_name, path, res