mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Minor formatting changes to ProgressReader. Newlines when complete
This commit is contained in:
parent
e614690f07
commit
3686feaccc
1 changed files with 5 additions and 1 deletions
|
@ -113,13 +113,17 @@ func (r *progressReader) Read(p []byte) (n int, err error) {
|
|||
|
||||
// Only update progress for every 1% read
|
||||
update_every := int(0.01 * float64(r.read_total))
|
||||
if r.read_progress - r.last_update > update_every {
|
||||
if r.read_progress - r.last_update > update_every || r.read_progress == r.read_total {
|
||||
fmt.Fprintf(r.output, "%d/%d (%.0f%%)\r",
|
||||
r.read_progress,
|
||||
r.read_total,
|
||||
float64(r.read_progress) / float64(r.read_total) * 100)
|
||||
r.last_update = r.read_progress
|
||||
}
|
||||
// Send newline when complete
|
||||
if err == io.EOF {
|
||||
fmt.Fprintf(r.output, "\n")
|
||||
}
|
||||
|
||||
return read, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue