From db2ad7d83ca22f4c1a1eabf4d4f45ce6273979a5 Mon Sep 17 00:00:00 2001 From: Patrick Simpson Date: Wed, 14 Jun 2017 16:08:11 +0200 Subject: [PATCH] [KOE-115] Added lastsynctime to automatic resync check. --- .../Features/SyncState/FeatureSyncState.cs | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs index ce7978e..7519300 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs @@ -99,6 +99,7 @@ namespace Acacia.Features.SyncState /// private DateTime? _syncStallStarted; private bool _syncStallAsked; + private DateTime? _syncStallLastSyncTime; #endregion @@ -308,6 +309,11 @@ namespace Acacia.Features.SyncState { get { return _data.data.contentdata; } } + + public DateTime LastSyncTime + { + get { return _data.data.lastsynctime; } + } } private class GetDeviceDetailsRequest : SoapRequest @@ -322,6 +328,7 @@ namespace Acacia.Features.SyncState public long Total { get; private set; } public long Done { get; private set; } public bool IsSyncing { get; private set; } + public DateTime? LastSyncTime { get; private set; } private readonly FeatureSyncState _feature; private readonly ZPushAccount _account; @@ -340,6 +347,8 @@ namespace Acacia.Features.SyncState { StringBuilder debug = new StringBuilder(); + LastSyncTime = details.LastSyncTime; + // If a folder is no longer reported as it's already synced, we don't necessarily get the // last step where (done == total). This causes some folders to keep lingering. To clean these // up, keep a list of folders syncing in this iteration. @@ -495,16 +504,24 @@ namespace Acacia.Features.SyncState string syncId = (string)inbox.GetProperty(OutlookConstants.PR_ZPUSH_SYNC_ID); // If it's syncing, it's not stalled - if (syncId != null && syncId != "0") - return; + //if (syncId != null && syncId != "0") + // return; - // Check if the folder has synced. In that case, it's not stalled. + SyncSession sync = account.GetFeatureData(this, null); + + // If the last sync time hasn't changed, it hasn't actually synced yet + if (sync.LastSyncTime != null && _syncStallLastSyncTime == sync.LastSyncTime) + return; + _syncStallLastSyncTime = sync.LastSyncTime; + + // Get the sync state string folderId = (string)inbox.GetProperty(OutlookConstants.PR_ZPUSH_FOLDER_ID); if (folderId != null) { - SyncSession sync = account.GetFeatureData(this, null); + + // Check if the folder has synced. In that case, it's not stalled. if (sync.HasFolderSynced(folderId)) - return; + return; } }