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 Jan 29, 2024
1 parent e779777 commit 737570e
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 @@ -102,16 +102,16 @@ class FilesSyncWork(

@Suppress("MagicNumber")
override suspend 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))
setForeground(createForegroundInfo(0))

// 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 737570e

Please sign in to comment.