mirror of
https://github.com/chatmail/core.git
synced 2026-05-12 19:36:32 +03:00
fix: Imap::configure_mvbox: Do select_with_uidvalidity() before return
Before moving emails to the mvbox we need to remember its UIDVALIDITY, otherwise emails moved before that wouldn't be fetched but considered "old" instead. Also: - Don't use `session.create()` to create mvbox as `select_with_uidvalidity()` already creates mvbox on its own. - Don't try to create compat folders like "INBOX.DeltaChat", but only look for them.
This commit is contained in:
30
src/imap.rs
30
src/imap.rs
@@ -1775,7 +1775,7 @@ impl Imap {
|
|||||||
/// Attempts to configure mvbox.
|
/// Attempts to configure mvbox.
|
||||||
///
|
///
|
||||||
/// Tries to find any folder in the given list of `folders`. If none is found, tries to create
|
/// Tries to find any folder in the given list of `folders`. If none is found, tries to create
|
||||||
/// any of them in the same order. This method does not use LIST command to ensure that
|
/// `folders[0]`. This method does not use LIST command to ensure that
|
||||||
/// configuration works even if mailbox lookup is forbidden via Access Control List (see
|
/// configuration works even if mailbox lookup is forbidden via Access Control List (see
|
||||||
/// <https://datatracker.ietf.org/doc/html/rfc4314>).
|
/// <https://datatracker.ietf.org/doc/html/rfc4314>).
|
||||||
///
|
///
|
||||||
@@ -1804,24 +1804,28 @@ impl Imap {
|
|||||||
"MVBOX-folder {:?} successfully selected, using it.", &folder
|
"MVBOX-folder {:?} successfully selected, using it.", &folder
|
||||||
);
|
);
|
||||||
session.close().await?;
|
session.close().await?;
|
||||||
|
// Before moving emails to the mvbox we need to remember its UIDVALIDITY, otherwise
|
||||||
|
// emails moved before that wouldn't be fetched but considered "old" instead.
|
||||||
|
self.select_with_uidvalidity(context, folder).await?;
|
||||||
return Ok(Some(folder));
|
return Ok(Some(folder));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if create_mvbox {
|
if !create_mvbox {
|
||||||
for folder in folders {
|
return Ok(None);
|
||||||
match session.create(&folder).await {
|
}
|
||||||
Ok(_) => {
|
let Some(folder) = folders.first() else {
|
||||||
info!(context, "MVBOX-folder {} created.", &folder);
|
return Ok(None);
|
||||||
return Ok(Some(folder));
|
};
|
||||||
}
|
match self.select_with_uidvalidity(context, folder).await {
|
||||||
Err(err) => {
|
Ok(_) => {
|
||||||
warn!(context, "Cannot create MVBOX-folder {:?}: {}", &folder, err);
|
info!(context, "MVBOX-folder {} created.", folder);
|
||||||
}
|
return Ok(Some(folder));
|
||||||
}
|
}
|
||||||
|
Err(err) => {
|
||||||
|
warn!(context, "Cannot create MVBOX-folder {:?}: {}", folder, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user