Skip to content

Commit

Permalink
Add checks for progress bar updates
Browse files Browse the repository at this point in the history
Add check to verify that changing the max is required.

Add check to avoid that current values exceeds current max.
  • Loading branch information
HeavyWombat committed Jul 29, 2024
1 parent 8dd141e commit 4f1f03d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/shp/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func min(a, b int64) int64 {
if a < b {
return a
}
return b
}

// GetSourceBundleImage returns the source bundle image of the build that is
// associated with the provided buildrun, an empty string if source bundle is
// not used, or an error in case the build cannot be obtained
Expand Down Expand Up @@ -98,8 +105,11 @@ func Push(ctx context.Context, io *genericclioptions.IOStreams, localDirectory s
defer progress.Close()
}

progress.ChangeMax64(update.Total)
_ = progress.Set64(update.Complete)
if update.Total != progress.GetMax64() {
progress.ChangeMax64(update.Total)
}

_ = progress.Set64(min(update.Complete, update.Total))
}
}
}()
Expand Down

0 comments on commit 4f1f03d

Please sign in to comment.