diff --git a/src/ApiService/ApiService/onefuzzlib/JobOperations.cs b/src/ApiService/ApiService/onefuzzlib/JobOperations.cs index beb2e3480..5510e1dfb 100644 --- a/src/ApiService/ApiService/onefuzzlib/JobOperations.cs +++ b/src/ApiService/ApiService/onefuzzlib/JobOperations.cs @@ -7,6 +7,7 @@ public interface IJobOperations : IStatefulOrm { Async.Task OnStart(Job job); IAsyncEnumerable SearchExpired(); Async.Task Stopping(Job job); + Async.Task Init(Job job); IAsyncEnumerable SearchState(IEnumerable states); Async.Task StopNeverStartedJobs(); Async.Task StopIfAllDone(Job job); @@ -73,6 +74,17 @@ public class JobOperations : StatefulOrm, IJobOper } } + public async Async.Task Init(Job job) { + _logTracer.Info($"init job: {job.JobId}"); + var enabled = job with { State = JobState.Enabled }; + var result = await Replace(enabled); + if (result.IsOk) { + return enabled; + } else { + throw new Exception($"Failed to save job {job.JobId} : {result.ErrorV}"); + } + } + public async Async.Task Stopping(Job job) { job = job with { State = JobState.Stopping }; var tasks = await _context.TaskOperations.QueryAsync(filter: $"job_id eq '{job.JobId}'").ToListAsync();