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

Fix panic when the prefix is > 61 chars #182

Merged
merged 1 commit into from
Feb 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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