Browse Source

imap/untagged.rs: properly queue refresh events

RefreshEvents where added in self.uid_store.refresh_events queue though
ImapConnection has a method add_refresh_event() that drains the queue if
possible
master
parent
commit
64e5d4af4f
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS. GPG Key ID: 73627C2F690DF710
1 changed files with 21 additions and 32 deletions
  1. +21
    -32
      melib/src/backends/imap/untagged.rs

+ 21
- 32
melib/src/backends/imap/untagged.rs View File

@@ -42,7 +42,7 @@ impl ImapConnection {
Err(err.clone()),
);
debug!("failure: {}", err.to_string());
self.uid_store.refresh_events.lock().unwrap().push(RefreshEvent {
self.add_refresh_event(RefreshEvent {
account_hash: self.uid_store.account_hash,
mailbox_hash: $mailbox_hash,
kind: RefreshEventKind::Failure(err.clone()),
@@ -167,13 +167,11 @@ impl ImapConnection {
if !env.is_seen() {
*mailbox.unseen.lock().unwrap() += 1;
}
self.uid_store.refresh_events.lock().unwrap().push(
RefreshEvent {
account_hash: self.uid_store.account_hash,
mailbox_hash,
kind: Create(Box::new(env)),
},
);
self.add_refresh_event(RefreshEvent {
account_hash: self.uid_store.account_hash,
mailbox_hash,
kind: Create(Box::new(env)),
});
}
}
}
@@ -258,13 +256,11 @@ impl ImapConnection {
*mailbox.unseen.lock().unwrap() += 1;
}

self.uid_store.refresh_events.lock().unwrap().push(
RefreshEvent {
account_hash: self.uid_store.account_hash,
mailbox_hash,
kind: Create(Box::new(env)),
},
);
self.add_refresh_event(RefreshEvent {
account_hash: self.uid_store.account_hash,
mailbox_hash,
kind: Create(Box::new(env)),
});
}
}
}
@@ -307,23 +303,16 @@ impl ImapConnection {
{
Ok(mut v) => {
if let Some(uid) = v.pop() {
if let Some(env_hash) = self
.uid_store
.uid_index
.lock()
.unwrap()
.get(&(mailbox_hash, uid))
{
self.uid_store
.refresh_events
.lock()
.unwrap()
.push(RefreshEvent {
account_hash: self.uid_store.account_hash,
mailbox_hash,
kind: NewFlags(*env_hash, flags),
});
}
let lck = self.uid_store.uid_index.lock().unwrap();
let env_hash = lck.get(&(mailbox_hash, uid)).map(|&h| h);
drop(lck);
if let Some(env_hash) = env_hash {
self.add_refresh_event(RefreshEvent {
account_hash: self.uid_store.account_hash,
mailbox_hash,
kind: NewFlags(env_hash, flags),
});
};
}
}
Err(e) => {


Loading…
Cancel
Save