提交 8e505f29 作者: Jeromy

fix progress bar in add

License: MIT
Signed-off-by: 's avatarJeromy <why@ipfs.io>
上级 6e5420e5
......@@ -131,11 +131,16 @@ func (f *serialFile) Size() (int64, error) {
}
var du int64
err := filepath.Walk(f.FileName(), func(p string, fi os.FileInfo, err error) error {
err := filepath.Walk(f.FullPath(), func(p string, fi os.FileInfo, err error) error {
if err != nil {
return err
}
if fi != nil && fi.Mode()&(os.ModeSymlink|os.ModeNamedPipe) == 0 {
du += fi.Size()
}
return nil
})
return du, err
}
......@@ -242,22 +242,13 @@ You can now refer to the added file in a gateway, like so:
}
var bar *pb.ProgressBar
var terminalWidth int
if progress {
bar = pb.New64(0).SetUnits(pb.U_BYTES)
bar.ManualUpdate = true
bar.ShowTimeLeft = false
bar.ShowPercent = false
bar.Output = res.Stderr()
bar.Start()
// the progress bar lib doesn't give us a way to get the width of the output,
// so as a hack we just use a callback to measure the output, then git rid of it
terminalWidth = 0
bar.Callback = func(line string) {
terminalWidth = len(line)
bar.Callback = nil
bar.Output = res.Stderr()
log.Infof("terminal width: %v\n", terminalWidth)
}
bar.Update()
}
var sizeChan chan int64
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论