From 16573e9ea632f423e2c6d5088da8890144173ab6 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Wed, 12 Apr 2023 11:41:24 +0200 Subject: [PATCH] Sync interval failure (#235) * Fix log message * Log a warning if repairing the sync interval failed --- .../davdroid/settings/AccountSettings.kt | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/at/bitfire/davdroid/settings/AccountSettings.kt b/app/src/main/java/at/bitfire/davdroid/settings/AccountSettings.kt index 3931b792..20dfd59e 100644 --- a/app/src/main/java/at/bitfire/davdroid/settings/AccountSettings.kt +++ b/app/src/main/java/at/bitfire/davdroid/settings/AccountSettings.kt @@ -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) {