@@ -291,7 +291,7 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
291
291
}
292
292
293
293
task .LogFilename = logFileName (job .Run .Repo .FullName (), task .ID )
294
- if _ , err := e . ID ( task . ID ). Cols ( "log_filename" ). Update ( task ); err != nil {
294
+ if err := UpdateTask ( ctx , task , "log_filename" ); err != nil {
295
295
return nil , false , err
296
296
}
297
297
@@ -367,9 +367,18 @@ func UpdateTaskByState(ctx context.Context, state *runnerv1.TaskState) (*ActionT
367
367
return nil , util .ErrNotExist
368
368
}
369
369
370
+ if task .Status .IsDone () {
371
+ // the state is final, do nothing
372
+ return task , nil
373
+ }
374
+
375
+ // state.Result is not unspecified means the task is finished
370
376
if state .Result != runnerv1 .Result_RESULT_UNSPECIFIED {
371
377
task .Status = Status (state .Result )
372
378
task .Stopped = timeutil .TimeStamp (state .StoppedAt .AsTime ().Unix ())
379
+ if err := UpdateTask (ctx , task , "status" , "stopped" ); err != nil {
380
+ return nil , err
381
+ }
373
382
if _ , err := UpdateRunJob (ctx , & ActionRunJob {
374
383
ID : task .JobID ,
375
384
Status : task .Status ,
@@ -379,10 +388,6 @@ func UpdateTaskByState(ctx context.Context, state *runnerv1.TaskState) (*ActionT
379
388
}
380
389
}
381
390
382
- if _ , err := e .ID (task .ID ).Update (task ); err != nil {
383
- return nil , err
384
- }
385
-
386
391
if err := task .LoadAttributes (ctx ); err != nil {
387
392
return nil , err
388
393
}
@@ -440,7 +445,7 @@ func StopTask(ctx context.Context, taskID int64, status Status) error {
440
445
return err
441
446
}
442
447
443
- if _ , err := e . ID ( task . ID ). Update ( task ); err != nil {
448
+ if err := UpdateTask ( ctx , task , "status" , "stopped" ); err != nil {
444
449
return err
445
450
}
446
451
0 commit comments