cmd/uplink: fix progress bar crash
the progress bar was being set to inconsistent lengths multiple times, causing a crash. this fixes that by only setting the progress bar length once to the length of the full object. it avoids a round trip by doing so only after it has gotten the first read handle from the source, so the length information is cached. Change-Id: I112d7c79016e54ba3794e96c6174cc01b8baedb4
This commit is contained in:
parent
d701f9f081
commit
b70fb2f87f
@ -525,6 +525,14 @@ func (c *cmdCp) parallelCopy(
|
||||
break
|
||||
}
|
||||
|
||||
if i == 0 && bar != nil {
|
||||
info, err := src.Info(ctx)
|
||||
if err == nil {
|
||||
bar.SetTotal(info.ContentLength, false)
|
||||
bar.EnableTriggerComplete()
|
||||
}
|
||||
}
|
||||
|
||||
wh, err := dst.NextPart(ctx, chunk)
|
||||
if err != nil {
|
||||
_ = rh.Close()
|
||||
@ -546,12 +554,8 @@ func (c *cmdCp) parallelCopy(
|
||||
|
||||
var w io.Writer = wh
|
||||
if bar != nil {
|
||||
bar.SetTotal(rh.Info().ContentLength, false)
|
||||
bar.EnableTriggerComplete()
|
||||
pw := bar.ProxyWriter(w)
|
||||
defer func() {
|
||||
_ = pw.Close()
|
||||
}()
|
||||
defer func() { _ = pw.Close() }()
|
||||
w = pw
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user