From 76171c8be0aa14c8e98e1906c88d089037f1a3b4 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Fri, 20 Sep 2024 16:19:39 +0200 Subject: [PATCH] feat: Add logs for sync start conditions --- .../e/drive/periodicScan/FullScanWorker.kt | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/periodicScan/FullScanWorker.kt b/app/src/main/java/foundation/e/drive/periodicScan/FullScanWorker.kt index bd655a1c..194dea8d 100644 --- a/app/src/main/java/foundation/e/drive/periodicScan/FullScanWorker.kt +++ b/app/src/main/java/foundation/e/drive/periodicScan/FullScanWorker.kt @@ -97,19 +97,38 @@ class FullScanWorker(private val context: Context, private val workerParams: Wor private fun checkStartConditions(account: Account?, prefs : SharedPreferences, requestCollector: SyncRequestCollector): Boolean { Timber.d("FullScanWorker.checkStartConditions()") - if (account == null) return false + if (account == null) { + Timber.w("Account is null") + return false + } - if (!isSetupDone(prefs)) return false + if (!isSetupDone(prefs)) { + Timber.w("Setup is not done") + return false + } - if (isFileSyncDisabled(account)) return false //@todo could be replaced by checking list of sync folders not empty after loading them + // TODO: could be replaced by checking list of sync folders not empty after loading them + if (isFileSyncDisabled(account)) { + Timber.w("File synchronization is disabled") + return false + } val forcedSync = workerParams.inputData.getBoolean(ACTION_FORCED_SYNC_KEY, false) - if (!forcedSync && !isMinimumDelayRespected(prefs)) return false + if (!forcedSync && !isMinimumDelayRespected(prefs)) { + Timber.w("Minimum delay not respected") + return false + } - if (!isConnectedToAllowedNetwork(account)) return false + if (!isConnectedToAllowedNetwork(account)) { + Timber.w("Not connected to allowed network") + return false + } - if (!requestCollector.onPeriodicScanStart(applicationContext as Application)) return false + if (!requestCollector.onPeriodicScanStart(applicationContext as Application)) { + Timber.w("Periodic scan start is not allowed") + return false + } return true } -- GitLab