Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 76171c8b authored by Jonathan Klee's avatar Jonathan Klee
Browse files

feat: Add logs for sync start conditions

parent 16223069
Loading
Loading
Loading
Loading
Loading
+25 −6
Original line number Diff line number Diff line
@@ -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
    }