Skip to content

Commit

Permalink
Bug/not modified fix (eu-digital-green-certificates#297)
Browse files Browse the repository at this point in the history
* - fix handling of 304 code. When 304 received usaCase should skip next steps;

* - update time of revocation reload;
  • Loading branch information
MykhailoNester committed Mar 29, 2022
1 parent e99e5d8 commit e798c13
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import okhttp3.ResponseBody
interface RevocationRepository {

@Throws(Exception::class)
suspend fun getRevocationLists(): List<RevocationKidData>
suspend fun getRevocationLists(): List<RevocationKidData>?

@Throws(Exception::class)
suspend fun getRevocationPartitions(sliceType: SliceType, kid: String): List<RevocationPartitionResponse>?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ class GetRevocationDataUseCase @Inject constructor(
errorHandler: ErrorHandler,
) : BaseUseCase<Unit, Any>(dispatcher, errorHandler) {

private val sliceType = SliceType.VARHASHLIST
private val sliceType = SliceType.BLOOMFILTER

override suspend fun invoke(params: Any) {
revocationPreferences.lastRevocationSyncTimeMillis = System.currentTimeMillis()

// Load list of KIDs
val newKidItems = repository.getRevocationLists()
val newKidItems = repository.getRevocationLists() ?: return

// Remove all entities not matching KIDs from list
repository.deleteOutdatedKidItems(newKidItems.map { it.kid })
Expand All @@ -70,8 +72,6 @@ class GetRevocationDataUseCase @Inject constructor(

// Delete expired data
repository.deleteExpiredData(ChronoUnit.MICROS.between(Instant.EPOCH, ZonedDateTime.now().toInstant()))

revocationPreferences.lastRevocationSyncTimeMillis = System.currentTimeMillis()
}

private suspend fun checkKidMetadata(revocationKidData: RevocationKidData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class RevocationRepositoryImpl @Inject constructor(
) : RevocationRepository {

@Throws(Exception::class)
override suspend fun getRevocationLists(): List<RevocationKidData> {
override suspend fun getRevocationLists(): List<RevocationKidData>? {
val eTag = revocationPreferences.eTag ?: ""
val response = revocationService.getRevocationLists(eTag)

Expand All @@ -59,7 +59,7 @@ class RevocationRepositoryImpl @Inject constructor(
revocationPreferences.eTag = response.headers()["eTag"]?.replace("\"", "")
response.body()?.map { it.toRevocationKidData() } ?: emptyList()
} else {
emptyList()
null
}
}

Expand Down

0 comments on commit e798c13

Please sign in to comment.