Method WithdrawDuplicatedSentCopiesAsync
- Namespace
- MailFathom.Application.Mail.Delivery.Filing
- Assembly
- MailFathom.Application.dll
WithdrawDuplicatedSentCopiesAsync(MailAccountId, CancellationToken)
Takes back the sent copies whose provider has since filed one of its own beside them.
public Task<IReadOnlyList<OutgoingMailFilingResult>> WithdrawDuplicatedSentCopiesAsync(MailAccountId account, CancellationToken cancellationToken)
Parameters
accountMailAccountIdThe account whose sent folder is brought back to one copy of each message.
cancellationTokenCancellationTokenCancels the read and the withdrawals.
Returns
- Task<IReadOnlyList<OutgoingMailFilingResult>>
What each withdrawal did, which is empty on an account that has asked for none.
Remarks
A provider that files the sent copy itself does it asynchronously, so nothing before the send can tell whether it will. What can be told, once synchronization has met a second occurrence of the message in the same folder, is that the folder now holds two — and the one this system appended is the one it may take back out.
It runs on the outbox pass rather than on the synchronization run that discovers the duplicate, because taking a message out of a folder is a write and no read path may obtain the session that makes one. The cost is one query per pass on an account whose sent folder holds no duplicate, which is every account whose provider files nothing. A held account withdraws nothing: its source is drained, and a copy appended there while it was still mirrored is the drain's to remove.
One pass withdraws no more copies than it delivers sends, for the reason the mirror is bounded by that same number: each is one conversation with a server, and what one pass leaves the next one takes. A record an erasure removed between the read and the withdrawal is passed over rather than reported, because the copy it named belongs to a message this deployment no longer holds.