Skip to content

Commit

Permalink
fix upload log
Browse files Browse the repository at this point in the history
  • Loading branch information
zc2638 committed Jan 17, 2024
1 parent 5660c1d commit 7d279a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
12 changes: 6 additions & 6 deletions core/handler/client/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,22 +503,22 @@ func handleLogUpload() http.HandlerFunc {

ctx := r.Context()
ll := livelog.FromContext(ctx)
lineCount := ll.LineCount(ctx, stepID)
if lineCount == len(lines) {
ctr.Success(w)
return
}

var opts []any
if isAll {
lineCount := ll.LineCount(ctx, stepID)
if lineCount == len(lines) {
ctr.Success(w)
return
}
if err := ll.Reset(ctx, stepID); err != nil {
ctr.InternalError(w, err)
return
}
opts = []any{livelog.PublishOption(false)}
}
for _, line := range lines {
if err := ll.Write(ctx, stepID, line, opts); err != nil {
if err := ll.Write(ctx, stepID, line, opts...); err != nil {
ctr.InternalError(w, err)
return
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/livelog/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ func (w *writer) Write(p []byte) (n int, err error) {
}

func (w *writer) Close() error {
select {
case _, ok := <-w.closeCh:
if !ok {
return nil
}
default:
}
w.closeCh <- struct{}{}

for {
Expand Down

0 comments on commit 7d279a7

Please sign in to comment.