Table of Contents

Method UpsertMetadataAsync

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

UpsertMetadataAsync(IPersistenceSession, RemoteEmailMetadata, ExtractedEmailMetadata?, StoredEmailContentAvailability, CancellationToken)

Inserts or updates metadata for one remote occurrence idempotently and returns its stable local identity.

Task<StoredEmailId> UpsertMetadataAsync(IPersistenceSession session, RemoteEmailMetadata metadata, ExtractedEmailMetadata? extractedMetadata, StoredEmailContentAvailability contentAvailability, CancellationToken cancellationToken)

Parameters

session IPersistenceSession

The explicit persistence session this metadata write participates in.

metadata RemoteEmailMetadata

The remote occurrence metadata to store.

extractedMetadata ExtractedEmailMetadata

What was read out of the occurrence's raw MIME, or null when nothing was read from it.

contentAvailability StoredEmailContentAvailability

Whether raw MIME content is stored for this occurrence, or why it is not.

cancellationToken CancellationToken

Propagates caller cancellation.

Returns

Task<StoredEmailId>

The stable local identifier of the inserted or existing stored email.

Remarks

Absent extracted metadata is one state rather than several: nothing was read from this occurrence's MIME, whether because the payload was never fetched or because no reader could parse it. Which of those happened is already carried by contentAvailability and by the run's own counters, and neither changes what this write can record. The fields only extraction supplies — participants, the received timestamp, thread ancestors, and the attachment summary — keep whatever an earlier run wrote rather than being cleared, because the remote message is immutable and a reader that fails this time is no reason to forget what it read last time.