Skip to content

Commit

Permalink
Fix to many returns in doWork
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Mayer <[email protected]>
  • Loading branch information
JonasMayerDev committed Apr 9, 2024
1 parent d56c342 commit 6c85372
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/src/main/java/com/nextcloud/client/jobs/FilesSyncWork.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6c85372

Please sign in to comment.