Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #182 from blalor/panic-drawing-progress-bar
Browse files Browse the repository at this point in the history
Fix panic when the prefix is > 61 chars
  • Loading branch information
Derek Gonyeo committed Feb 26, 2016
2 parents dd71391 + fab1f99 commit 1bf95ab
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions registry/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,14 @@ func (r Registry) download(url, path, label string) error {
func newIoprogress(label string, size int64, rdr io.Reader) io.Reader {
prefix := "Downloading " + label
fmtBytesSize := 18

// if barSize < 2, drawing the bar will panic; 3 will at least give a spinny
// thing.
barSize := int64(80 - len(prefix) - fmtBytesSize)
if barSize < 2 {
barSize = 2
}

bar := ioprogress.DrawTextFormatBarForW(barSize, os.Stderr)
fmtfunc := func(progress, total int64) string {
// Content-Length is set to -1 when unknown.
Expand Down

0 comments on commit 1bf95ab

Please sign in to comment.