Fix to many returns in doWork

Signed-off-by: Jonas Mayer <jonas.a.mayer@gmx.net>
This commit is contained in:
Jonas Mayer 2024-01-18 13:49:36 +01:00 committed by Jonas Mayer
parent 24b1fa2da7
commit 575e413b8d

View file

@ -94,15 +94,15 @@ class FilesSyncWork(
@Suppress("MagicNumber")
override fun doWork(): Result {
if (backgroundJobManager.bothFilesSyncJobsRunning()) {
Log_OC.d(TAG, "Kill Sync Worker since another instance of the worker seems to be running already!")
return Result.success()
}
backgroundJobManager.logStartOfWorker(BackgroundJobManagerImpl.formatClassTag(this::class))
// If we are in power save mode or sync worker already running, better to postpone upload
val overridePowerSaving = inputData.getBoolean(OVERRIDE_POWER_SAVING, false)
// If we are in power save mode, better to postpone upload
if (powerManagementService.isPowerSavingEnabled && !overridePowerSaving) {
val alreadyRunning = backgroundJobManager.bothFilesSyncJobsRunning()
if ((powerManagementService.isPowerSavingEnabled && !overridePowerSaving) || alreadyRunning) {
if (alreadyRunning) {
Log_OC.d(TAG, "Kill Sync Worker since another instance of the worker seems to be running already!")
}
val result = Result.success()
backgroundJobManager.logEndOfWorker(BackgroundJobManagerImpl.formatClassTag(this::class), result)
return result