mirror of
https://github.com/bitwarden/android.git
synced 2025-02-16 20:09:59 +03:00
BIT-2080: Sync time updated when sync is not needed (#1144)
This commit is contained in:
parent
226b62a1cd
commit
1a41fcb5c8
2 changed files with 13 additions and 5 deletions
|
@ -331,6 +331,10 @@ class VaultRepositoryImpl(
|
|||
if (serverRevisionDate < lastSyncInstant) {
|
||||
// We can skip the actual sync call if there is no new data
|
||||
vaultDiskSource.resyncVaultData(userId)
|
||||
settingsDiskSource.storeLastSyncTime(
|
||||
userId = userId,
|
||||
lastSyncTime = clock.instant(),
|
||||
)
|
||||
return@launch
|
||||
}
|
||||
},
|
||||
|
@ -369,7 +373,10 @@ class VaultRepositoryImpl(
|
|||
userId = userId,
|
||||
policies = syncResponse.policies,
|
||||
)
|
||||
settingsDiskSource.storeLastSyncTime(userId = userId, clock.instant())
|
||||
settingsDiskSource.storeLastSyncTime(
|
||||
userId = userId,
|
||||
lastSyncTime = clock.instant(),
|
||||
)
|
||||
vaultDiskSource.replaceVaultData(userId = userId, vault = syncResponse)
|
||||
},
|
||||
onFailure = { throwable ->
|
||||
|
|
|
@ -159,9 +159,8 @@ class VaultRepositoryTest {
|
|||
private val fileManager: FileManager = mockk()
|
||||
private val fakeAuthDiskSource = FakeAuthDiskSource()
|
||||
private val settingsDiskSource = mockk<SettingsDiskSource> {
|
||||
every {
|
||||
getLastSyncTime(userId = any())
|
||||
} returns clock.instant()
|
||||
every { getLastSyncTime(userId = any()) } returns clock.instant()
|
||||
every { storeLastSyncTime(userId = any(), lastSyncTime = any()) } just runs
|
||||
}
|
||||
private val syncService: SyncService = mockk {
|
||||
coEvery {
|
||||
|
@ -965,13 +964,15 @@ class VaultRepositoryTest {
|
|||
fun `sync when the last sync time is more recent than the revision date should not sync `() {
|
||||
val userId = "mockId-1"
|
||||
fakeAuthDiskSource.userState = MOCK_USER_STATE
|
||||
coEvery { syncService.sync() } just awaits
|
||||
every {
|
||||
settingsDiskSource.getLastSyncTime(userId = userId)
|
||||
} returns clock.instant().plus(2, ChronoUnit.MINUTES)
|
||||
|
||||
vaultRepository.sync()
|
||||
|
||||
verify(exactly = 1) {
|
||||
settingsDiskSource.storeLastSyncTime(userId = userId, lastSyncTime = clock.instant())
|
||||
}
|
||||
coVerify(exactly = 0) { syncService.sync() }
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue