Table of Contents

Method ApplyReconciliationOutcomeAsync

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

ApplyReconciliationOutcomeAsync(IPersistenceSession, ReconciledFolderOutcome, CancellationToken)

Applies everything one window learned, as one bounded set of writes.

Task ApplyReconciliationOutcomeAsync(IPersistenceSession session, ReconciledFolderOutcome outcome, CancellationToken cancellationToken)

Parameters

session IPersistenceSession

The explicit persistence session the whole outcome participates in.

outcome ReconciledFolderOutcome

What the window found, and what becomes of the emails the folder no longer holds.

cancellationToken CancellationToken

Propagates caller cancellation.

Returns

Task

A task that completes when the writes have been staged.

Remarks

The whole window is applied at once so the work is bounded by the window rather than by a query per email held inside an open write transaction. An implementation reads the rows it needs in one bounded query keyed by the identities the outcome names.

Every write is idempotent and none of them moves state backwards, which is what makes replaying a window after a commit conflict safe. An occurrence whose stored observation is newer than this window's is left alone: another writer has since asked the same server and its answer supersedes this one, including when this window would have deleted the email. A tombstone keeps the timestamp of the run that first observed the disappearance, and a row another writer already removed is not an error to remove again.

Removing a row removes the raw MIME, the derived text and index entry, and every other artifact derived from the message with it, because a deletion that leaves derived data behind is not one.