@cryptotaxi247 / kubo / commits / 8e505f291

fix progress bar in add

License: MIT Signed-off-by: Jeromy <why@ipfs.io>

Jeromy committed Jun 22, 2016 at 17:09 UTC 8e505f291fe84d28538d796c3cb2774c2399cd1d
2 files changed +9 -13
commands/files/serialfile.go
+6 -1
@@ -131,11 +131,16 @@ func (f *serialFile) Size() (int64, error) {
131 }
132
133 var du int64
134 - err := filepath.Walk(f.FileName(), func(p string, fi os.FileInfo, err error) error {
134 + err := filepath.Walk(f.FullPath(), func(p string, fi os.FileInfo, err error) error {
135 + if err != nil {
136 + return err
137 + }
138 +
139 if fi != nil && fi.Mode()&(os.ModeSymlink|os.ModeNamedPipe) == 0 {
140 du += fi.Size()
141 }
142 return nil
143 })
144 +
145 return du, err
146 }
core/commands/add.go
+3 -12
@@ -242,22 +242,13 @@ You can now refer to the added file in a gateway, like so:
242 }
243
244 var bar *pb.ProgressBar
245 - var terminalWidth int
245 if progress {
246 bar = pb.New64(0).SetUnits(pb.U_BYTES)
247 bar.ManualUpdate = true
248 + bar.ShowTimeLeft = false
249 + bar.ShowPercent = false
250 + bar.Output = res.Stderr()
251 bar.Start()
250 -
251 - // the progress bar lib doesn't give us a way to get the width of the output,
252 - // so as a hack we just use a callback to measure the output, then git rid of it
253 - terminalWidth = 0
254 - bar.Callback = func(line string) {
255 - terminalWidth = len(line)
256 - bar.Callback = nil
257 - bar.Output = res.Stderr()
258 - log.Infof("terminal width: %v\n", terminalWidth)
259 - }
260 - bar.Update()
252 }
253
254 var sizeChan chan int64