Skip to content

Commit

Permalink
handle progress for 0 sized files
Browse files Browse the repository at this point in the history
  • Loading branch information
cenkalti committed Jun 25, 2021
1 parent 27f8a03 commit 278a86e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ func (r *Progress) Start() {
func (r *Progress) run() {
for range r.ticker.C {
offset := atomic.LoadInt64(&r.offset)
progress := (offset * 100) / r.size
var progress int64
if r.size != 0 {
progress = (offset * 100) / r.size
}
speed := r.counter.Rate() / (1 << 10)
log.Infof("%s %d/%d MB (%d%%) %d KB/s", r.prefix, offset/(1<<20), r.size/(1<<20), progress, speed)
}
Expand Down

0 comments on commit 278a86e

Please sign in to comment.