Method TryCarryToOccurrenceAsync
- Namespace
- MailFathom.Application.Synchronization
- Assembly
- MailFathom.Application.dll
TryCarryToOccurrenceAsync(IPersistenceSession, StoredEmailId, EmailOccurrenceId, CancellationToken)
Moves one stored email onto the occurrence a relocation put it at, instead of storing a second email there.
Task<bool> TryCarryToOccurrenceAsync(IPersistenceSession session, StoredEmailId storedEmailId, EmailOccurrenceId occurrenceId, CancellationToken cancellationToken)
Parameters
sessionIPersistenceSessionThe explicit persistence session this write participates in.
storedEmailIdStoredEmailIdThe email that was relocated, named by the mutation record.
occurrenceIdEmailOccurrenceIdWhere the destination folder now holds it.
cancellationTokenCancellationTokenPropagates caller cancellation.
Returns
- Task<bool>
true when the row was carried across; false when another row already occupies the occurrence.
Remarks
Only the occurrence identity moves. The raw MIME, the extracted metadata, the search document, and the passages are all keyed by the local identity and describe a message that a relocation did not change, so re-deriving any of them would spend a fetch and a parse to arrive back where they already are.
The flags become unobserved rather than being carried over as observed. What is stored still describes the message, but it was read in the folder the email has left, and the destination folder's own reconciliation window is what says whether it still holds.
An occurrence another row already occupies is reported rather than written, because the occurrence identity is unique and a caller cannot decide for the mailbox which of two local emails is the one the server holds there. The caller then stores the discovery as it would any other, which leaves a duplicate visible instead of failing the run.
Exceptions
- ArgumentNullException
Thrown when
occurrenceIdis null.- InvalidOperationException
Thrown when no stored email carries
storedEmailId, or when the occurrence names a folder binding that is not stored.