提交 d6f14d69 编写于 作者: A Anders F Björklund

Abbreviate too long filenames to show progress

When the prefix string gets too long, the cheggaaa/pb
progress bar library doesn't show the remaining time.
上级 fff47bd5
......@@ -48,6 +48,11 @@ func (cpb *progressBar) TrackProgress(src string, currentSize, totalSize int64,
}
p := pb.Full.Start64(totalSize)
fn := filepath.Base(src)
// abbreviate filename for progress
maxwidth := 30 - len("...")
if len(fn) > maxwidth {
fn = fn[0:maxwidth] + "..."
}
p.Set("prefix", " > "+fn+": ")
p.SetCurrent(currentSize)
p.Set(pb.Bytes, true)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册