Sync interval failure (#235)

* Fix log message

* Log a warning if repairing the sync interval failed
This commit is contained in:
Michael Biebl 2023-04-12 11:41:24 +02:00 committed by GitHub
parent e2bfda71bc
commit 16573e9ea6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -159,29 +159,35 @@ class AccountSettings(
// repair address book sync
settings.getSavedAddressbooksSyncInterval()?.let { shouldBe ->
val current = settings.getSyncInterval(addressBooksAuthority)
val authority = addressBooksAuthority
val current = settings.getSyncInterval(authority)
if (current != shouldBe) {
Logger.log.warning("${account.name}: $addressBooksAuthority sync interval should be $shouldBe but is $current -> setting to $current")
settings.setSyncInterval(addressBooksAuthority, shouldBe)
Logger.log.warning("${account.name}: $authority sync interval should be $shouldBe but is $current -> setting to $shouldBe")
if (!settings.setSyncInterval(authority, shouldBe))
Logger.log.warning("${account.name}: repairing/setting the sync interval for $authority failed")
}
}
// repair calendar sync
settings.getSavedCalendarsSyncInterval()?.let { shouldBe ->
val current = settings.getSyncInterval(CalendarContract.AUTHORITY)
val authority = CalendarContract.AUTHORITY
val current = settings.getSyncInterval(authority)
if (current != shouldBe) {
Logger.log.warning("${account.name}: ${CalendarContract.AUTHORITY} sync interval should be $shouldBe but is $current -> setting to $current")
settings.setSyncInterval(CalendarContract.AUTHORITY, shouldBe)
Logger.log.warning("${account.name}: $authority sync interval should be $shouldBe but is $current -> setting to $shouldBe")
if (!settings.setSyncInterval(authority, shouldBe))
Logger.log.warning("${account.name}: repairing/setting the sync interval for $authority failed")
}
}
if (taskAuthority != null)
// repair calendar sync
settings.getSavedTasksSyncInterval()?.let { shouldBe ->
val current = settings.getSyncInterval(taskAuthority)
val authority = taskAuthority
val current = settings.getSyncInterval(authority)
if (current != shouldBe) {
Logger.log.warning("${account.name}: $taskAuthority sync interval should be $shouldBe but is $current -> setting to $current")
settings.setSyncInterval(taskAuthority, shouldBe)
Logger.log.warning("${account.name}: $authority sync interval should be $shouldBe but is $current -> setting to $shouldBe")
if (!settings.setSyncInterval(authority, shouldBe))
Logger.log.warning("${account.name}: repairing/setting the sync interval for $authority failed")
}
}
} catch (ignored: InvalidAccountException) {