aboutsummaryrefslogtreecommitdiff
path: root/src/mail/user.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mail/user.rs')
-rw-r--r--src/mail/user.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/mail/user.rs b/src/mail/user.rs
index 0be3801..ea22d5b 100644
--- a/src/mail/user.rs
+++ b/src/mail/user.rs
@@ -69,12 +69,22 @@ impl User {
/// Opens an existing mailbox given its IMAP name.
pub async fn open_mailbox(&self, name: &str) -> Result<Option<Arc<Mailbox>>> {
- let (list, _ct) = self.load_mailbox_list().await?;
- match list.get(name) {
+ let (mut list, ct) = self.load_mailbox_list().await?;
+ match list.get_mut(name) {
Some(MailboxListEntry {
id_lww: (_, Some(mbid)),
uidvalidity,
- }) => self.open_mailbox_by_id(*mbid, *uidvalidity).await,
+ }) => {
+ let mb_opt = self.open_mailbox_by_id(*mbid, *uidvalidity).await?;
+ if let Some(mb) = &mb_opt {
+ let mb_uidvalidity = mb.current_uid_index().await.uidvalidity;
+ if mb_uidvalidity > *uidvalidity {
+ *uidvalidity = mb_uidvalidity;
+ self.save_mailbox_list(&list, ct).await?;
+ }
+ }
+ Ok(mb_opt)
+ }
_ => bail!("Mailbox does not exist: {}", name),
}
}