Skip to content

Commit b43250a

Browse files
committed
fix: don't update log for done task
1 parent c794edb commit b43250a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

routers/api/actions/runner/runner.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,19 +210,22 @@ func (s *Service) UpdateLog(
210210

211211
task, err := actions_model.GetTaskByID(ctx, req.Msg.TaskId)
212212
if err != nil {
213+
if errors.Is(err, util.ErrNotExist) {
214+
return nil, status.Errorf(codes.NotFound, "task %d not found", req.Msg.TaskId)
215+
}
213216
return nil, status.Errorf(codes.Internal, "get task: %v", err)
214217
}
218+
if task.Status.IsDone() {
219+
return nil, status.Errorf(codes.FailedPrecondition, "task %d is done", req.Msg.TaskId)
220+
}
221+
215222
ack := task.LogLength
216223

217224
if len(req.Msg.Rows) == 0 || req.Msg.Index > ack || int64(len(req.Msg.Rows))+req.Msg.Index <= ack {
218225
res.Msg.AckIndex = ack
219226
return res, nil
220227
}
221228

222-
if task.LogInStorage {
223-
return nil, status.Errorf(codes.AlreadyExists, "log file has been archived")
224-
}
225-
226229
rows := req.Msg.Rows[ack-req.Msg.Index:]
227230
ns, err := actions.WriteLogs(ctx, task.LogFilename, task.LogSize, rows)
228231
if err != nil {

0 commit comments

Comments
 (0)