progressui: fix possible out of order indexing on plain mode

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
master
Tonis Tiigi 2022-02-28 23:37:51 -08:00
parent 578f045d5c
commit 379ac1b1f7
2 changed files with 10 additions and 9 deletions

View File

@ -119,7 +119,6 @@ type trace struct {
localTimeDiff time.Duration
vertexes []*vertex
byDigest map[digest.Digest]*vertex
nextIndex int
updates map[digest.Digest]struct{}
modeConsole bool
groups map[string]*vertexGroup // group id -> group
@ -410,7 +409,6 @@ func (t *trace) update(s *client.SolveStatus, termWidth int) {
if v.ProgressGroup != nil {
group, ok := t.groups[v.ProgressGroup.Id]
if !ok {
t.nextIndex++
group = &vertexGroup{
vertex: &vertex{
Vertex: &client.Vertex{
@ -419,7 +417,6 @@ func (t *trace) update(s *client.SolveStatus, termWidth int) {
},
byID: make(map[string]*status),
statusUpdates: make(map[string]struct{}),
index: t.nextIndex,
intervals: make(map[int64]interval),
hidden: true,
},
@ -441,11 +438,9 @@ func (t *trace) update(s *client.SolveStatus, termWidth int) {
}
prev, ok := t.byDigest[v.Digest]
if !ok {
t.nextIndex++
t.byDigest[v.Digest] = &vertex{
byID: make(map[string]*status),
statusUpdates: make(map[string]struct{}),
index: t.nextIndex,
intervals: make(map[int64]interval),
}
if t.modeConsole {

View File

@ -27,10 +27,11 @@ type lastStatus struct {
}
type textMux struct {
w io.Writer
current digest.Digest
last map[string]lastStatus
notFirst bool
w io.Writer
current digest.Digest
last map[string]lastStatus
notFirst bool
nextIndex int
}
func (p *textMux) printVtx(t *trace, dgst digest.Digest) {
@ -43,6 +44,11 @@ func (p *textMux) printVtx(t *trace, dgst digest.Digest) {
return
}
if v.index == 0 {
p.nextIndex++
v.index = p.nextIndex
}
if dgst != p.current {
if p.current != "" {
old := t.byDigest[p.current]