Table of Contents

Class MailboxReconciler

Namespace
MailFathom.Application.Synchronization.Reconciliation
Assembly
MailFathom.Application.dll

Brings the local copy of one folder back in line with what the mail server still holds.

public sealed class MailboxReconciler
Inheritance
MailboxReconciler
Inherited Members

Remarks

This is the backward half of a synchronization run. The forward half only ever moves past the checkpoint, so it can discover a new email and can never notice that an old one is gone or that its flags have changed; this pass walks a bounded window of what is already stored and asks the server about it.

The window is chosen by how long ago each occurrence was last observed and is bounded per run, so a large mailbox is reconciled over many runs rather than scanned in one. Writing an observation is what moves an occurrence to the back of that queue, which is why the pass needs no cursor of its own and why an interrupted run resumes rather than restarts.

Everything it does against the server is read-only. It asks for flags and for nothing that could set the remote \Seen flag, and it holds no port that could write one back — which is the structural form of the invariant this pass is the riskiest place in the system for.

A disappearance is not by itself somebody else's act. MailFathom relocates and deletes mail on the server too, and the occurrence leaving its folder is those changes completing rather than a remote deletion to react to. The durable mutation record is what tells the two apart, so the pass reads it before the disposition is reached.

The same holds of a \Seen flag that has moved, and there it is the whole difficulty. A flag change arrives as a changed modification sequence, which is the identical signal a person marking mail read in their own client produces, so a rule conditioned on unread mail that marks mail read would re-evaluate everything it had just acted on. The record answers it, and both halves of that answer are recorded in the window's own transaction so a change can never be marked accounted for by a window whose reading of it was rolled back.

Constructors

MailboxReconciler(IStoredEmailReconciliationStore, IMailboxMutationReconciliationStore, IRemotelyDeletedEmailDispositionReader, OptimisticConcurrencyRetryPolicy, TimeProvider, MailboxSynchronizationOptions)

Initializes a new mailbox reconciler.

Methods

ReconcileAsync(IMailboxSession, MailAccountId, MailFolderResolution, ImapUidValidity, ulong?, CancellationToken)

Reconciles one bounded window of the folder the supplied session has open.