aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-06-30 16:04:38 +0200
committerAlex Auvolat <alex@adnab.me>2022-06-30 16:04:51 +0200
commit3277fb16a84d1b7335a4590d69a3c65229204370 (patch)
tree7b64769fc1c28b51533be5468e508775cf8d38be
parent90c20a840dfdbb47ddc63725baa04feafec0ee1b (diff)
downloadaerogramme-3277fb16a84d1b7335a4590d69a3c65229204370.tar.gz
aerogramme-3277fb16a84d1b7335a4590d69a3c65229204370.zip
update uid in mailbox list when opening mailbox
-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),
}
}