Fix recursive sync
This commit is contained in:
@@ -43,10 +43,12 @@ class SyncController @Inject constructor(
|
|||||||
private val defaultGcPeriod = TimeUnit.DAYS.toMillis(2) // gc period if sync disabled
|
private val defaultGcPeriod = TimeUnit.DAYS.toMillis(2) // gc period if sync disabled
|
||||||
|
|
||||||
override fun onInvalidated(tables: Set<String>) {
|
override fun onInvalidated(tables: Set<String>) {
|
||||||
requestSync(
|
val favourites = (TABLE_FAVOURITES in tables || TABLE_FAVOURITE_CATEGORIES in tables)
|
||||||
favourites = TABLE_FAVOURITES in tables || TABLE_FAVOURITE_CATEGORIES in tables,
|
&& !isSyncActiveOrPending(authorityFavourites)
|
||||||
history = TABLE_HISTORY in tables,
|
val history = TABLE_HISTORY in tables && !isSyncActiveOrPending(authorityHistory)
|
||||||
)
|
if (favourites || history) {
|
||||||
|
requestSync(favourites, history)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isEnabled(account: Account): Boolean {
|
fun isEnabled(account: Account): Boolean {
|
||||||
@@ -126,6 +128,11 @@ class SyncController @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun isSyncActiveOrPending(authority: String): Boolean {
|
||||||
|
val account = peekAccount() ?: return false
|
||||||
|
return ContentResolver.isSyncActive(account, authority) || ContentResolver.isSyncPending(account, authority)
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|||||||
Reference in New Issue
Block a user