Incremental sync only every 30 minutes

This commit is contained in:
Kyle Spearrin 2016-07-28 21:41:45 -04:00
parent bb4b732b76
commit 7b76f2c238
3 changed files with 15 additions and 2 deletions

View file

@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
namespace Bit.App.Abstractions
{
@ -9,6 +10,7 @@ namespace Bit.App.Abstractions
Task<bool> SyncDeleteFolderAsync(string id);
Task<bool> SyncDeleteSiteAsync(string id);
Task<bool> FullSyncAsync();
Task<bool> IncrementalSyncAsync(TimeSpan syncThreshold);
Task<bool> IncrementalSyncAsync();
}
}

View file

@ -125,7 +125,7 @@ namespace Bit.App
{
try
{
await _syncService.IncrementalSyncAsync();
await _syncService.IncrementalSyncAsync(TimeSpan.FromMinutes(30));
break;
}
catch(WebException)

View file

@ -167,6 +167,17 @@ namespace Bit.App.Services
return true;
}
public async Task<bool> IncrementalSyncAsync(TimeSpan syncThreshold)
{
DateTime? lastSync = _settings.GetValueOrDefault<DateTime?>(LastSyncKey);
if(lastSync != null && DateTime.UtcNow - lastSync.Value < syncThreshold)
{
return false;
}
return await IncrementalSyncAsync();
}
public async Task<bool> IncrementalSyncAsync()
{
if(!_authService.IsAuthenticated)