Update dav4jvm

This commit is contained in:
Ricki Hirner
2025-05-09 11:50:45 +02:00
parent 827a1b954f
commit d460e4ca7b
2 changed files with 8 additions and 42 deletions

View File

@@ -37,9 +37,6 @@ import at.bitfire.davdroid.repository.DavServiceRepository
import at.bitfire.davdroid.repository.DavSyncStatsRepository
import at.bitfire.davdroid.resource.LocalCollection
import at.bitfire.davdroid.resource.LocalResource
import at.bitfire.davdroid.sync.SyncManager.Companion.DELAY_UNTIL_DEFAULT
import at.bitfire.davdroid.sync.SyncManager.Companion.DELAY_UNTIL_MAX
import at.bitfire.davdroid.sync.SyncManager.Companion.DELAY_UNTIL_MIN
import at.bitfire.davdroid.sync.account.InvalidAccountException
import at.bitfire.ical4android.CalendarStorageException
import at.bitfire.vcard4android.ContactsStorageException
@@ -53,7 +50,6 @@ import java.io.IOException
import java.io.InterruptedIOException
import java.net.HttpURLConnection
import java.security.cert.CertificateException
import java.time.Instant
import java.util.LinkedList
import java.util.concurrent.LinkedBlockingQueue
import java.util.logging.Level
@@ -96,39 +92,15 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L
/** Maximum number of resources that are requested with one multiget request. */
const val MAX_MULTIGET_RESOURCES = 10
const val DELAY_UNTIL_DEFAULT = 15*60L // 15 min
const val DELAY_UNTIL_MIN = 1*60L // 1 min
const val DELAY_UNTIL_MAX = 2*60*60L // 2 hours
/**
* Returns appropriate sync retry delay in seconds, considering the servers suggestion
* ([DELAY_UNTIL_DEFAULT] if no server suggestion).
*
* Takes current time into account to calculate intervals. Interval
* will be restricted to values between [DELAY_UNTIL_MIN] and [DELAY_UNTIL_MAX].
*
* @param retryAfter optional server suggestion on how long to wait before retrying
* @return until when to wait before sync can be retried
*/
fun getDelayUntil(retryAfter: Instant?): Instant {
val now = Instant.now()
if (retryAfter == null)
return now.plusSeconds(DELAY_UNTIL_DEFAULT)
// take server suggestion, but restricted to plausible min/max values
val min = now.plusSeconds(DELAY_UNTIL_MIN)
val max = now.plusSeconds(DELAY_UNTIL_MAX)
return when {
min > retryAfter -> min
max < retryAfter -> max
else -> retryAfter
}
}
}
@Inject
lateinit var accountRepository: AccountRepository
@Inject
lateinit var collectionRepository: DavCollectionRepository
@Inject
@ApplicationContext
lateinit var context: Context
@@ -136,18 +108,12 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L
@Inject
lateinit var logger: Logger
@Inject
lateinit var accountRepository: AccountRepository
@Inject
lateinit var syncStatsRepository: DavSyncStatsRepository
@Inject
lateinit var serviceRepository: DavServiceRepository
@Inject
lateinit var collectionRepository: DavCollectionRepository
@Inject
lateinit var syncNotificationManagerFactory: SyncNotificationManager.Factory
@@ -318,7 +284,7 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L
is ServiceUnavailableException -> {
logger.log(Level.WARNING, "Got 503 Service unavailable, trying again later", e)
// determine when to retry
syncResult.delayUntil = getDelayUntil(e.retryAfter).epochSecond
syncResult.delayUntil = e.getDelayUntil().epochSecond
syncResult.numServiceUnavailableExceptions++ // Indicate a soft error occurred
}

View File

@@ -19,7 +19,7 @@ androidx-test-rules = "1.6.1"
androidx-test-junit = "1.2.1"
androidx-work = "2.10.1"
bitfire-cert4android = "b67ba86d31"
bitfire-dav4jvm = "9678c50130"
bitfire-dav4jvm = "ec6264d427"
bitfire-ical4android = "21622fef29"
bitfire-vcard4android = "59eb998f29"
compose-accompanist = "0.37.3"