Fix progress bar update regression (#2976)
Regression introduced in cf6defe025
This commit is contained in:
committed by
kannappanr
parent
4e316c3a40
commit
1e1480f408
+7
-3
@@ -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
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user