Fix progress bar update regression (#2976)

Regression introduced in cf6defe025
This commit is contained in:
Harshavardhana
2019-11-30 17:19:23 -08:00
committed by kannappanr
parent 4e316c3a40
commit 1e1480f408
2 changed files with 11 additions and 7 deletions
+7 -3
View File
@@ -267,6 +267,7 @@ func (mj *mirrorJob) doMirror(ctx context.Context, cancelMirror context.CancelFu
// and accounting readers under relevant conditions.
if mj.isFake {
mj.status.Add(sURLs.SourceContent.Size)
mj.status.Update()
return sURLs.WithError(nil)
}
@@ -440,7 +441,8 @@ func (mj *mirrorJob) watchMirror(ctx context.Context, cancelMirror context.Cance
if shouldQueue || mj.isOverwrite {
// adjust total, because we want to show progress of
// the item still queued to be copied.
mj.status.SetTotal(mj.status.Get() + sourceContent.Size).Update()
mj.status.Add(sourceContent.Size)
mj.status.SetTotal(mj.status.Get()).Update()
mj.status.AddCounts(1)
mirrorURL.TotalSize = mj.status.Get()
mirrorURL.TotalCount = mj.status.GetCounts()
@@ -470,7 +472,8 @@ func (mj *mirrorJob) watchMirror(ctx context.Context, cancelMirror context.Cance
mirrorURL.SourceContent.Size = event.Size
// adjust total, because we want to show progress
// of the itemj stiil queued to be copied.
mj.status.SetTotal(mj.status.Get() + mirrorURL.SourceContent.Size).Update()
mj.status.Add(mirrorURL.SourceContent.Size)
mj.status.SetTotal(mj.status.Get()).Update()
mj.status.AddCounts(1)
mirrorURL.TotalSize = mj.status.Get()
mirrorURL.TotalCount = mj.status.GetCounts()
@@ -541,8 +544,9 @@ func (mj *mirrorJob) startMirror(ctx context.Context, cancelMirror context.Cance
}
}
mj.status.AddCounts(1)
mj.status.Add(sURLs.SourceContent.Size)
mj.status.SetTotal(mj.status.Get()).Update()
mj.status.AddCounts(1)
// Save total count.
sURLs.TotalCount = mj.status.GetCounts()
+4 -4
View File
@@ -87,7 +87,7 @@ func (qs *QuietStatus) AddCounts(v int64) {
// SetTotal sets the total of the progressbar, ignored for quietstatus
func (qs *QuietStatus) SetTotal(v int64) Status {
qs.accounter.Total = v
qs.accounter.Set(v)
return qs
}
@@ -102,7 +102,7 @@ func (qs *QuietStatus) Get() int64 {
// Total returns the total number of bytes
func (qs *QuietStatus) Total() int64 {
return qs.accounter.Total
return qs.accounter.Get()
}
// Add bytes to current number of bytes
@@ -189,12 +189,12 @@ func (ps *ProgressStatus) Get() int64 {
// Total returns the total number of bytes
func (ps *ProgressStatus) Total() int64 {
return ps.progressBar.Total
return ps.progressBar.Get()
}
// SetTotal sets the total of the progressbar
func (ps *ProgressStatus) SetTotal(v int64) Status {
ps.progressBar.Total = v
ps.progressBar.SetTotal(v)
return ps
}