Skip to content

Commit

Permalink
Scheduler: Tweak rescheduling behavior
Browse files Browse the repository at this point in the history
See #692
  • Loading branch information
d4rken committed Nov 28, 2023
1 parent cf080e0 commit 6979752
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class SchedulerManager @Inject constructor(

workManager.enqueueUniqueWork(
workName,
if (reschedule) ExistingWorkPolicy.APPEND else ExistingWorkPolicy.REPLACE,
if (reschedule) ExistingWorkPolicy.APPEND_OR_REPLACE else ExistingWorkPolicy.REPLACE,
workRequest
).await()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ class SchedulerWorker @AssistedInject constructor(
val duration = System.currentTimeMillis() - start
log(TAG, INFO) { "Execution finished after ${duration}ms: $schedule" }

schedulerManager.reschedule(scheduleId)

Result.success(inputData)
} catch (e: Throwable) {
if (e !is CancellationException) {
Expand All @@ -99,6 +97,7 @@ class SchedulerWorker @AssistedInject constructor(
} finally {
schedulerNotifications.cancel(scheduleId)
workerScope.cancel("Worker finished (withError?=$finishedWithError).")
schedulerManager.reschedule(scheduleId)
}

private suspend fun doDoWork(schedule: Schedule) {
Expand Down

0 comments on commit 6979752

Please sign in to comment.