Fix for another sequence contains error.
This commit is contained in:
@@ -645,7 +645,7 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="messageIds">Gmail message ids to download.</param>
|
/// <param name="messageIds">Gmail message ids to download.</param>
|
||||||
/// <param name="cancellationToken">Cancellation token.</param>
|
/// <param name="cancellationToken">Cancellation token.</param>
|
||||||
private async Task BatchDownloadMessagesAsync(IEnumerable<string> messageIds, CancellationToken cancellationToken = default)
|
private async Task BatchDownloadMessagesAsync(List<string> messageIds, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var totalDownloadCount = messageIds.Count();
|
var totalDownloadCount = messageIds.Count();
|
||||||
|
|
||||||
@@ -660,7 +660,7 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
|
|||||||
// Respect the batch size limit for batch requests.
|
// Respect the batch size limit for batch requests.
|
||||||
var batchedDownloadRequests = allDownloadRequests.Batch((int)MaximumAllowedBatchRequestSize);
|
var batchedDownloadRequests = allDownloadRequests.Batch((int)MaximumAllowedBatchRequestSize);
|
||||||
|
|
||||||
_logger.Debug("Total items to download: {TotalDownloadCount}. Created {Count} batch download requests for {Name}.", batchedDownloadRequests.Count(), Account.Name, totalDownloadCount);
|
_logger.Information("Total items to download: {TotalDownloadCount}. Created {Count} batch download requests for {Name}.", batchedDownloadRequests.Count(), Account.Name, totalDownloadCount);
|
||||||
|
|
||||||
// Gmail SDK's BatchRequest has Action delegate for callback, not Task.
|
// Gmail SDK's BatchRequest has Action delegate for callback, not Task.
|
||||||
// Therefore it's not possible to make sure that downloaded item is processed in the database before this
|
// Therefore it's not possible to make sure that downloaded item is processed in the database before this
|
||||||
@@ -712,9 +712,9 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
|
|||||||
|
|
||||||
if (historyIdMessages.Any())
|
if (historyIdMessages.Any())
|
||||||
{
|
{
|
||||||
var maxHistoryId = batchProcessCallbacks.Select(a => a.Result).Where(a => a?.HistoryId != null).Max(a => a.HistoryId.Value);
|
var maxHistoryId = historyIdMessages.Max(a => a.HistoryId.Value);
|
||||||
|
|
||||||
if (maxHistoryId != 0)
|
if (maxHistoryId > 0)
|
||||||
{
|
{
|
||||||
Account.SynchronizationDeltaIdentifier = await _gmailChangeProcessor.UpdateAccountDeltaSynchronizationIdentifierAsync(Account.Id, maxHistoryId.ToString()).ConfigureAwait(false);
|
Account.SynchronizationDeltaIdentifier = await _gmailChangeProcessor.UpdateAccountDeltaSynchronizationIdentifierAsync(Account.Id, maxHistoryId.ToString()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@@ -1060,7 +1060,7 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
|
|||||||
var downloadRequireMessageIds = messageIds.Except(await _gmailChangeProcessor.AreMailsExistsAsync(messageIds));
|
var downloadRequireMessageIds = messageIds.Except(await _gmailChangeProcessor.AreMailsExistsAsync(messageIds));
|
||||||
|
|
||||||
// Download missing messages.
|
// Download missing messages.
|
||||||
await BatchDownloadMessagesAsync(downloadRequireMessageIds, cancellationToken);
|
await BatchDownloadMessagesAsync(downloadRequireMessageIds.ToList(), cancellationToken);
|
||||||
|
|
||||||
// Get results from database and return.
|
// Get results from database and return.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user