Skip to content

Commit 295326a

Browse files
committed
fix: upload sync messages only with the primary transport
Currently there is a race between transports to upload sync messages and delete them from `imap_send` table. Sometimes mulitple transports upload the same message and sometimes only some of them "win". With this change only the primary transport will upload the sync message.
1 parent db066ca commit 295326a

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/imap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub(crate) struct Imap {
7979
pub(crate) idle_interrupt_receiver: Receiver<()>,
8080

8181
/// Email address.
82-
addr: String,
82+
pub(crate) addr: String,
8383

8484
/// Login parameters.
8585
lp: Vec<ConfiguredServerLoginParam>,

src/scheduler.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -578,12 +578,19 @@ async fn fetch_idle(
578578
mvbox.as_deref().unwrap_or(&watch_folder)
579579
}
580580
};
581-
session
582-
.send_sync_msgs(ctx, syncbox)
583-
.await
584-
.context("fetch_idle: send_sync_msgs")
585-
.log_err(ctx)
586-
.ok();
581+
if ctx
582+
.get_config(Config::ConfiguredAddr)
583+
.await?
584+
.unwrap_or_default()
585+
== connection.addr
586+
{
587+
session
588+
.send_sync_msgs(ctx, syncbox)
589+
.await
590+
.context("fetch_idle: send_sync_msgs")
591+
.log_err(ctx)
592+
.ok();
593+
}
587594

588595
session
589596
.store_seen_flags_on_imap(ctx)

0 commit comments

Comments
 (0)