Fixing remote highest mode seq checks for qresync and condstore synchronizers.
This commit is contained in:
@@ -45,21 +45,20 @@ namespace Wino.Core.Synchronizers.ImapSync
|
|||||||
await remoteFolder.OpenAsync(FolderAccess.ReadOnly, cancellationToken).ConfigureAwait(false);
|
await remoteFolder.OpenAsync(FolderAccess.ReadOnly, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var localHighestModSeq = (ulong)folder.HighestModeSeq;
|
var localHighestModSeq = (ulong)folder.HighestModeSeq;
|
||||||
var remoteHighestModSeq = remoteFolder.HighestModSeq;
|
|
||||||
|
|
||||||
bool isInitialSynchronization = localHighestModSeq == 0;
|
bool isInitialSynchronization = localHighestModSeq == 0;
|
||||||
|
|
||||||
// There are some changes on new messages or flag changes.
|
// There are some changes on new messages or flag changes.
|
||||||
// Deletions are tracked separately because some servers do not increase
|
// Deletions are tracked separately because some servers do not increase
|
||||||
// the MODSEQ value for deleted messages.
|
// the MODSEQ value for deleted messages.
|
||||||
if (remoteHighestModSeq > localHighestModSeq)
|
if (remoteFolder.HighestModSeq > localHighestModSeq)
|
||||||
{
|
{
|
||||||
var changedUids = await GetChangedUidsAsync(client, folder, remoteFolder, synchronizer, cancellationToken).ConfigureAwait(false);
|
var changedUids = await GetChangedUidsAsync(client, folder, remoteFolder, synchronizer, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
// Get locally exists mails for the returned UIDs.
|
// Get locally exists mails for the returned UIDs.
|
||||||
downloadedMessageIds = await HandleChangedUIdsAsync(folder, synchronizer, remoteFolder, changedUids, cancellationToken).ConfigureAwait(false);
|
downloadedMessageIds = await HandleChangedUIdsAsync(folder, synchronizer, remoteFolder, changedUids, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
folder.HighestModeSeq = (long)remoteHighestModSeq;
|
folder.HighestModeSeq = unchecked((long)remoteFolder.HighestModSeq);
|
||||||
|
|
||||||
await FolderService.UpdateFolderAsync(folder).ConfigureAwait(false);
|
await FolderService.UpdateFolderAsync(folder).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@@ -103,15 +102,15 @@ namespace Wino.Core.Synchronizers.ImapSync
|
|||||||
|
|
||||||
IList<UniqueId> changedUids = null;
|
IList<UniqueId> changedUids = null;
|
||||||
|
|
||||||
// TODO: Temporarily disabled.
|
if (winoClient.Capabilities.HasFlag(ImapCapabilities.Sort))
|
||||||
//if (winoClient.Capabilities.HasFlag(ImapCapabilities.Sort))
|
{
|
||||||
//{
|
// Highest mod seq must be greater than 0 for SORT.
|
||||||
// changedUids = await remoteFolder.SortAsync(SearchQuery.ChangedSince(localHighestModSeq), [OrderBy.ReverseDate], cancellationToken).ConfigureAwait(false);
|
changedUids = await remoteFolder.SortAsync(SearchQuery.ChangedSince(Math.Max(localHighestModSeq, 1)), [OrderBy.ReverseDate], cancellationToken).ConfigureAwait(false);
|
||||||
//}
|
}
|
||||||
//else
|
else
|
||||||
//{
|
{
|
||||||
// changedUids = await remoteFolder.SearchAsync(SearchQuery.ChangedSince(localHighestModSeq), cancellationToken).ConfigureAwait(false);
|
changedUids = await remoteFolder.SearchAsync(SearchQuery.ChangedSince(localHighestModSeq), cancellationToken).ConfigureAwait(false);
|
||||||
//}
|
}
|
||||||
|
|
||||||
changedUids = await remoteFolder.SearchAsync(SearchQuery.ChangedSince(localHighestModSeq), cancellationToken).ConfigureAwait(false);
|
changedUids = await remoteFolder.SearchAsync(SearchQuery.ChangedSince(localHighestModSeq), cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace Wino.Core.Synchronizers.ImapSync
|
|||||||
if (client is not WinoImapClient winoImapClient)
|
if (client is not WinoImapClient winoImapClient)
|
||||||
throw new System.ArgumentException("Client must be of type WinoImapClient.", nameof(client));
|
throw new System.ArgumentException("Client must be of type WinoImapClient.", nameof(client));
|
||||||
|
|
||||||
// if (client.Capabilities.HasFlag(ImapCapabilities.QuickResync) && winoImapClient.IsQResyncEnabled) return _qResyncSynchronizer;
|
if (client.Capabilities.HasFlag(ImapCapabilities.QuickResync) && winoImapClient.IsQResyncEnabled) return _qResyncSynchronizer;
|
||||||
if (client.Capabilities.HasFlag(ImapCapabilities.CondStore)) return _condstoreSynchronizer;
|
if (client.Capabilities.HasFlag(ImapCapabilities.CondStore)) return _condstoreSynchronizer;
|
||||||
|
|
||||||
return _uidBasedSynchronizer;
|
return _uidBasedSynchronizer;
|
||||||
|
|||||||
@@ -58,8 +58,6 @@ namespace Wino.Core.Synchronizers.ImapSync
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Perform QRESYNC synchronization.
|
// Perform QRESYNC synchronization.
|
||||||
|
|
||||||
var remoteHighestModSeq = remoteFolder.HighestModSeq;
|
|
||||||
var localHighestModSeq = (ulong)folder.HighestModeSeq;
|
var localHighestModSeq = (ulong)folder.HighestModeSeq;
|
||||||
|
|
||||||
remoteFolder.MessagesVanished += async (c, r) => await HandleMessageDeletedAsync(folder, r.UniqueIds).ConfigureAwait(false);
|
remoteFolder.MessagesVanished += async (c, r) => await HandleMessageDeletedAsync(folder, r.UniqueIds).ConfigureAwait(false);
|
||||||
@@ -75,7 +73,7 @@ namespace Wino.Core.Synchronizers.ImapSync
|
|||||||
downloadedMessageIds = await HandleChangedUIdsAsync(folder, synchronizer, remoteFolder, changedUids, cancellationToken).ConfigureAwait(false);
|
downloadedMessageIds = await HandleChangedUIdsAsync(folder, synchronizer, remoteFolder, changedUids, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
// Update the local folder with the new highest mod-seq and validity.
|
// Update the local folder with the new highest mod-seq and validity.
|
||||||
folder.HighestModeSeq = (long)remoteHighestModSeq;
|
folder.HighestModeSeq = unchecked((long)remoteFolder.HighestModSeq);
|
||||||
folder.UidValidity = remoteFolder.UidValidity;
|
folder.UidValidity = remoteFolder.UidValidity;
|
||||||
|
|
||||||
await ManageUUIdBasedDeletedMessagesAsync(folder, remoteFolder, cancellationToken).ConfigureAwait(false);
|
await ManageUUIdBasedDeletedMessagesAsync(folder, remoteFolder, cancellationToken).ConfigureAwait(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user