mirror of
https://github.com/chatmail/core.git
synced 2026-04-29 11:26:29 +03:00
refactor(imap): move resync request from Context to Imap
For multiple transports we will need to run multiple IMAP clients in parallel. UID validity change detected by one IMAP client should not result in UID resync for another IMAP client.
This commit is contained in:
@@ -206,7 +206,7 @@ impl ImapSession {
|
||||
"The server illegally decreased the uid_next of folder {folder:?} from {old_uid_next} to {new_uid_next} without changing validity ({new_uid_validity}), resyncing UIDs...",
|
||||
);
|
||||
set_uid_next(context, folder, new_uid_next).await?;
|
||||
context.schedule_resync().await?;
|
||||
self.resync_request_sender.try_send(()).ok();
|
||||
}
|
||||
|
||||
// If UIDNEXT changed, there are new emails.
|
||||
@@ -243,7 +243,7 @@ impl ImapSession {
|
||||
.await?;
|
||||
|
||||
if old_uid_validity != 0 || old_uid_next != 0 {
|
||||
context.schedule_resync().await?;
|
||||
self.resync_request_sender.try_send(()).ok();
|
||||
}
|
||||
info!(
|
||||
context,
|
||||
|
||||
@@ -48,6 +48,8 @@ pub(crate) struct Session {
|
||||
///
|
||||
/// Should be false if no folder is currently selected.
|
||||
pub new_mail: bool,
|
||||
|
||||
pub resync_request_sender: async_channel::Sender<()>,
|
||||
}
|
||||
|
||||
impl Deref for Session {
|
||||
@@ -68,6 +70,7 @@ impl Session {
|
||||
pub(crate) fn new(
|
||||
inner: ImapSession<Box<dyn SessionStream>>,
|
||||
capabilities: Capabilities,
|
||||
resync_request_sender: async_channel::Sender<()>,
|
||||
) -> Self {
|
||||
Self {
|
||||
inner,
|
||||
@@ -77,6 +80,7 @@ impl Session {
|
||||
selected_folder_needs_expunge: false,
|
||||
last_full_folder_scan: Mutex::new(None),
|
||||
new_mail: false,
|
||||
resync_request_sender,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user