Browse Source

melib: don't use both {set,push}_references()

set_references() already calls push_references()
lazy_fetch
Manos Pitsidianakis 11 months ago
parent
commit
24b4c117e7
Signed by: epilys GPG Key ID: 73627C2F690DF710
  1. 12
      melib/src/backends/imap.rs
  2. 24
      melib/src/backends/imap/cache/sync.rs
  3. 4
      melib/src/backends/imap/protocol_parser.rs
  4. 25
      melib/src/backends/imap/untagged.rs
  5. 12
      melib/src/backends/imap/watch.rs
  6. 4
      melib/src/backends/jmap/objects/email.rs
  7. 9
      melib/src/backends/nntp/protocol_parser.rs
  8. 9
      src/plugins/backend.rs

12
melib/src/backends/imap.rs

@ -1760,18 +1760,6 @@ async fn fetch_hlpr(state: &mut FetchState) -> Result<Vec<Envelope>> {
let env = envelope.as_mut().unwrap();
env.set_hash(generate_envelope_hash(&mailbox_path, &uid));
if let Some(value) = references {
let parse_result = crate::email::parser::address::msg_id_list(value);
if let Ok((_, value)) = parse_result {
let prev_val = env.references.take();
for v in value {
env.push_references(v);
}
if let Some(prev) = prev_val {
for v in prev.refs {
env.push_references(v);
}
}
}
env.set_references(value);
}
let mut tag_lck = uid_store.collection.tag_index.write().unwrap();

24
melib/src/backends/imap/cache/sync.rs

@ -157,18 +157,6 @@ impl ImapConnection {
let env = envelope.as_mut().unwrap();
env.set_hash(generate_envelope_hash(&mailbox_path, &uid));
if let Some(value) = references {
let parse_result = crate::email::parser::address::msg_id_list(value);
if let Ok((_, value)) = parse_result {
let prev_val = env.references.take();
for v in value {
env.push_references(v);
}
if let Some(prev) = prev_val {
for v in prev.refs {
env.push_references(v);
}
}
}
env.set_references(value);
}
let mut tag_lck = self.uid_store.collection.tag_index.write().unwrap();
@ -455,18 +443,6 @@ impl ImapConnection {
let env = envelope.as_mut().unwrap();
env.set_hash(generate_envelope_hash(&mailbox_path, &uid));
if let Some(value) = references {
let parse_result = crate::email::parser::address::msg_id_list(value);
if let Ok((_, value)) = parse_result {
let prev_val = env.references.take();
for v in value {
env.push_references(v);
}
if let Some(prev) = prev_val {
for v in prev.refs {
env.push_references(v);
}
}
}
env.set_references(value);
}
let mut tag_lck = self.uid_store.collection.tag_index.write().unwrap();

4
melib/src/backends/imap/protocol_parser.rs

@ -1318,7 +1318,9 @@ pub fn envelope(input: &[u8]) -> IResult<&[u8], Envelope> {
}
if let Some(in_reply_to) = in_reply_to {
env.set_in_reply_to(&in_reply_to);
env.push_references(env.in_reply_to().unwrap().clone());
if let Some(in_reply_to) = env.in_reply_to().cloned() {
env.push_references(in_reply_to);
}
}
if let Some(message_id) = message_id {

25
melib/src/backends/imap/untagged.rs

@ -224,18 +224,6 @@ impl ImapConnection {
let env = envelope.as_mut().unwrap();
env.set_hash(generate_envelope_hash(&mailbox.imap_path(), &uid));
if let Some(value) = references {
let parse_result = crate::email::parser::address::msg_id_list(value);
if let Ok((_, value)) = parse_result {
let prev_val = env.references.take();
for v in value {
env.push_references(v);
}
if let Some(prev) = prev_val {
for v in prev.refs {
env.push_references(v);
}
}
}
env.set_references(value);
}
let mut tag_lck = self.uid_store.collection.tag_index.write().unwrap();
@ -366,19 +354,6 @@ impl ImapConnection {
let env = envelope.as_mut().unwrap();
env.set_hash(generate_envelope_hash(&mailbox.imap_path(), &uid));
if let Some(value) = references {
let parse_result =
crate::email::parser::address::msg_id_list(value);
if let Ok((_, value)) = parse_result {
let prev_val = env.references.take();
for v in value {
env.push_references(v);
}
if let Some(prev) = prev_val {
for v in prev.refs {
env.push_references(v);
}
}
}
env.set_references(value);
}
let mut tag_lck = self.uid_store.collection.tag_index.write().unwrap();

12
melib/src/backends/imap/watch.rs

@ -374,18 +374,6 @@ pub async fn examine_updates(
let env = envelope.as_mut().unwrap();
env.set_hash(generate_envelope_hash(&mailbox.imap_path(), &uid));
if let Some(value) = references {
let parse_result = crate::email::parser::address::msg_id_list(value);
if let Ok((_, value)) = parse_result {
let prev_val = env.references.take();
for v in value {
env.push_references(v);
}
if let Some(prev) = prev_val {
for v in prev.refs {
env.push_references(v);
}
}
}
env.set_references(value);
}
let mut tag_lck = uid_store.collection.tag_index.write().unwrap();

4
melib/src/backends/jmap/objects/email.rs

@ -266,7 +266,9 @@ impl std::convert::From<EmailObject> for crate::Envelope {
}
if let Some(ref in_reply_to) = t.in_reply_to {
env.set_in_reply_to(in_reply_to[0].as_bytes());
env.push_references(env.in_reply_to().unwrap().clone());
if let Some(in_reply_to) = env.in_reply_to().cloned() {
env.push_references(in_reply_to);
}
}
if let Some(v) = t.headers.get("References") {
env.set_references(v.as_bytes());

9
melib/src/backends/nntp/protocol_parser.rs

@ -144,15 +144,6 @@ pub fn over_article(input: &str) -> IResult<&str, (UID, Envelope)> {
}
if let Some(references) = references {
{
if let Ok((_, r)) =
crate::email::parser::address::msg_id_list(references.as_bytes())
{
for v in r {
env.push_references(v);
}
}
}
env.set_references(references.as_bytes());
}

9
src/plugins/backend.rs

@ -155,15 +155,6 @@ impl MailBackend for PluginBackend {
env.set_subject(value);
}
if !references.is_empty() {
let parse_result =
melib::email::parser::address::references(
references.as_bytes(),
);
if parse_result.is_ok() {
for v in parse_result.unwrap().1 {
env.push_references(v);
}
}
env.set_references(references.as_bytes());
}

Loading…
Cancel
Save