updateRun method

  1. @override
bool updateRun(
  1. APICronJobRun run, {
  2. String? previousOwner,
})
override

Updates the stored run, only if the stored one is still APICronRunStatus.running and owned by previousOwner (default: the APICronJobRun.owner of run; another owner when taking an interrupted run over). false otherwise: the run was taken over by another instance, finished or deleted, and must not be overwritten.

Implementation

@override
bool updateRun(APICronJobRun run, {String? previousOwner}) {
  var key = _runKey(run.job, run.scheduledAt);
  var stored = _runs[key];
  if (stored == null ||
      stored.id != run.id ||
      stored.status != APICronRunStatus.running ||
      stored.owner != (previousOwner ?? run.owner)) {
    return false;
  }
  _runs[key] = run.copy();
  return true;
}