Skip to content

Commit d460e4c

Browse files
committed
Update dav4jvm
1 parent 827a1b9 commit d460e4c

File tree

2 files changed

+8
-42
lines changed

2 files changed

+8
-42
lines changed

app/src/main/kotlin/at/bitfire/davdroid/sync/SyncManager.kt

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ import at.bitfire.davdroid.repository.DavServiceRepository
3737
import at.bitfire.davdroid.repository.DavSyncStatsRepository
3838
import at.bitfire.davdroid.resource.LocalCollection
3939
import at.bitfire.davdroid.resource.LocalResource
40-
import at.bitfire.davdroid.sync.SyncManager.Companion.DELAY_UNTIL_DEFAULT
41-
import at.bitfire.davdroid.sync.SyncManager.Companion.DELAY_UNTIL_MAX
42-
import at.bitfire.davdroid.sync.SyncManager.Companion.DELAY_UNTIL_MIN
4340
import at.bitfire.davdroid.sync.account.InvalidAccountException
4441
import at.bitfire.ical4android.CalendarStorageException
4542
import at.bitfire.vcard4android.ContactsStorageException
@@ -53,7 +50,6 @@ import java.io.IOException
5350
import java.io.InterruptedIOException
5451
import java.net.HttpURLConnection
5552
import java.security.cert.CertificateException
56-
import java.time.Instant
5753
import java.util.LinkedList
5854
import java.util.concurrent.LinkedBlockingQueue
5955
import java.util.logging.Level
@@ -96,58 +92,28 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L
9692
/** Maximum number of resources that are requested with one multiget request. */
9793
const val MAX_MULTIGET_RESOURCES = 10
9894

99-
const val DELAY_UNTIL_DEFAULT = 15*60L // 15 min
100-
const val DELAY_UNTIL_MIN = 1*60L // 1 min
101-
const val DELAY_UNTIL_MAX = 2*60*60L // 2 hours
102-
103-
/**
104-
* Returns appropriate sync retry delay in seconds, considering the servers suggestion
105-
* ([DELAY_UNTIL_DEFAULT] if no server suggestion).
106-
*
107-
* Takes current time into account to calculate intervals. Interval
108-
* will be restricted to values between [DELAY_UNTIL_MIN] and [DELAY_UNTIL_MAX].
109-
*
110-
* @param retryAfter optional server suggestion on how long to wait before retrying
111-
* @return until when to wait before sync can be retried
112-
*/
113-
fun getDelayUntil(retryAfter: Instant?): Instant {
114-
val now = Instant.now()
115-
116-
if (retryAfter == null)
117-
return now.plusSeconds(DELAY_UNTIL_DEFAULT)
118-
119-
// take server suggestion, but restricted to plausible min/max values
120-
val min = now.plusSeconds(DELAY_UNTIL_MIN)
121-
val max = now.plusSeconds(DELAY_UNTIL_MAX)
122-
return when {
123-
min > retryAfter -> min
124-
max < retryAfter -> max
125-
else -> retryAfter
126-
}
127-
}
128-
12995
}
13096

13197

98+
@Inject
99+
lateinit var accountRepository: AccountRepository
100+
101+
@Inject
102+
lateinit var collectionRepository: DavCollectionRepository
103+
132104
@Inject
133105
@ApplicationContext
134106
lateinit var context: Context
135107

136108
@Inject
137109
lateinit var logger: Logger
138110

139-
@Inject
140-
lateinit var accountRepository: AccountRepository
141-
142111
@Inject
143112
lateinit var syncStatsRepository: DavSyncStatsRepository
144113

145114
@Inject
146115
lateinit var serviceRepository: DavServiceRepository
147116

148-
@Inject
149-
lateinit var collectionRepository: DavCollectionRepository
150-
151117
@Inject
152118
lateinit var syncNotificationManagerFactory: SyncNotificationManager.Factory
153119

@@ -318,7 +284,7 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L
318284
is ServiceUnavailableException -> {
319285
logger.log(Level.WARNING, "Got 503 Service unavailable, trying again later", e)
320286
// determine when to retry
321-
syncResult.delayUntil = getDelayUntil(e.retryAfter).epochSecond
287+
syncResult.delayUntil = e.getDelayUntil().epochSecond
322288
syncResult.numServiceUnavailableExceptions++ // Indicate a soft error occurred
323289
}
324290

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ androidx-test-rules = "1.6.1"
1919
androidx-test-junit = "1.2.1"
2020
androidx-work = "2.10.1"
2121
bitfire-cert4android = "b67ba86d31"
22-
bitfire-dav4jvm = "9678c50130"
22+
bitfire-dav4jvm = "ec6264d427"
2323
bitfire-ical4android = "21622fef29"
2424
bitfire-vcard4android = "59eb998f29"
2525
compose-accompanist = "0.37.3"

0 commit comments

Comments
 (0)