mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Improve updating Actions tasks (#24600)
Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
		| @@ -291,7 +291,7 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask | ||||
| 	} | ||||
|  | ||||
| 	task.LogFilename = logFileName(job.Run.Repo.FullName(), task.ID) | ||||
| 	if _, err := e.ID(task.ID).Cols("log_filename").Update(task); err != nil { | ||||
| 	if err := UpdateTask(ctx, task, "log_filename"); err != nil { | ||||
| 		return nil, false, err | ||||
| 	} | ||||
|  | ||||
| @@ -367,9 +367,18 @@ func UpdateTaskByState(ctx context.Context, state *runnerv1.TaskState) (*ActionT | ||||
| 		return nil, util.ErrNotExist | ||||
| 	} | ||||
|  | ||||
| 	if task.Status.IsDone() { | ||||
| 		// the state is final, do nothing | ||||
| 		return task, nil | ||||
| 	} | ||||
|  | ||||
| 	// state.Result is not unspecified means the task is finished | ||||
| 	if state.Result != runnerv1.Result_RESULT_UNSPECIFIED { | ||||
| 		task.Status = Status(state.Result) | ||||
| 		task.Stopped = timeutil.TimeStamp(state.StoppedAt.AsTime().Unix()) | ||||
| 		if err := UpdateTask(ctx, task, "status", "stopped"); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		if _, err := UpdateRunJob(ctx, &ActionRunJob{ | ||||
| 			ID:      task.JobID, | ||||
| 			Status:  task.Status, | ||||
| @@ -379,10 +388,6 @@ func UpdateTaskByState(ctx context.Context, state *runnerv1.TaskState) (*ActionT | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if _, err := e.ID(task.ID).Update(task); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	if err := task.LoadAttributes(ctx); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| @@ -440,7 +445,7 @@ func StopTask(ctx context.Context, taskID int64, status Status) error { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if _, err := e.ID(task.ID).Update(task); err != nil { | ||||
| 	if err := UpdateTask(ctx, task, "status", "stopped"); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user