progress: avoid double logs when multiple targets build same step

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2022-02-28 23:32:36 -08:00
parent 6efcee28d5
commit b77d7864fa
3 changed files with 55 additions and 11 deletions

View File

@ -10,6 +10,8 @@ import (
type Writer interface {
Write(*client.SolveStatus)
ValidateLogSource(digest.Digest, interface{}) bool
ClearLogSource(interface{})
}
func Write(w Writer, name string, f func() error) {
@ -47,8 +49,20 @@ func NewChannel(w Writer) (chan *client.SolveStatus, chan struct{}) {
v, ok := <-ch
if !ok {
close(done)
w.ClearLogSource(done)
return
}
if len(v.Logs) > 0 {
logs := make([]*client.VertexLog, 0, len(v.Logs))
for _, l := range v.Logs {
if w.ValidateLogSource(l.Vertex, done) {
logs = append(logs, l)
}
}
v.Logs = logs
}
w.Write(v)
}
}()