Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
Signed-off-by: Cabinfever_B <[email protected]>
  • Loading branch information
CabinfeverB committed Apr 1, 2024
1 parent dc62563 commit 1fbab5c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
30 changes: 8 additions & 22 deletions pkg/progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ const (
// Manager is used to maintain the progresses we care about.
type Manager struct {
syncutil.RWMutex
progesses map[string]*progressIndicator
progresses map[string]*progressIndicator
}

// NewManager creates a new Manager.
func NewManager() *Manager {
return &Manager{
progesses: make(map[string]*progressIndicator),
progresses: make(map[string]*progressIndicator),
}
}

Expand Down Expand Up @@ -81,7 +81,7 @@ func (m *Manager) Reset() {
m.Lock()
defer m.Unlock()

m.progesses = make(map[string]*progressIndicator)
m.progresses = make(map[string]*progressIndicator)
}

// Option is used to do some action for progressIndicator.
Expand All @@ -106,15 +106,6 @@ func (m *Manager) AddProgress(progress string, current, total float64, updateInt

history := list.New()
history.PushBack(current)
<<<<<<< HEAD
if _, exist = m.progesses[progress]; !exist {
m.progesses[progress] = &progressIndicator{
total: total,
remaining: total,
history: history,
windowLengthLimit: int(speedStatisticalWindow / updateInterval),
updateInterval: updateInterval,
=======
if _, exist = m.progresses[progress]; !exist {
pi := &progressIndicator{
total: total,
Expand All @@ -123,7 +114,6 @@ func (m *Manager) AddProgress(progress string, current, total float64, updateInt
windowCapacity: int(maxSpeedCalculationWindow/updateInterval) + 1,
windowLength: int(minSpeedCalculationWindow / updateInterval),
updateInterval: updateInterval,
>>>>>>> 945e29c03 (cluster: dynamic progress time window for offline scene (#7722))
}
for _, op := range opts {
op(pi)
Expand All @@ -140,14 +130,10 @@ func (m *Manager) UpdateProgress(progress string, current, remaining float64, is
m.Lock()
defer m.Unlock()

<<<<<<< HEAD
if p, exist := m.progesses[progress]; exist {
=======
if p, exist := m.progresses[progress]; exist {
for _, op := range opts {
op(p)
}
>>>>>>> 945e29c03 (cluster: dynamic progress time window for offline scene (#7722))
p.remaining = remaining
if p.total < remaining {
p.total = remaining
Expand Down Expand Up @@ -193,7 +179,7 @@ func (m *Manager) UpdateProgressTotal(progress string, total float64) {
m.Lock()
defer m.Unlock()

if p, exist := m.progesses[progress]; exist {
if p, exist := m.progresses[progress]; exist {
p.total = total
}
}
Expand All @@ -203,8 +189,8 @@ func (m *Manager) RemoveProgress(progress string) (exist bool) {
m.Lock()
defer m.Unlock()

if _, exist = m.progesses[progress]; exist {
delete(m.progesses, progress)
if _, exist = m.progresses[progress]; exist {
delete(m.progresses, progress)
return
}
return
Expand All @@ -216,7 +202,7 @@ func (m *Manager) GetProgresses(filter func(p string) bool) []string {
defer m.RUnlock()

processes := []string{}
for p := range m.progesses {
for p := range m.progresses {
if filter(p) {
processes = append(processes, p)
}
Expand All @@ -229,7 +215,7 @@ func (m *Manager) Status(progress string) (process, leftSeconds, currentSpeed fl
m.RLock()
defer m.RUnlock()

if p, exist := m.progesses[progress]; exist {
if p, exist := m.progresses[progress]; exist {
process = 1 - p.remaining/p.total
if process < 0 {
process = 0
Expand Down
4 changes: 0 additions & 4 deletions pkg/progress/progress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ func TestProgress(t *testing.T) {
for i := 0; i < 1000; i++ {
m.UpdateProgress(n, 30, 30, false)
}
<<<<<<< HEAD
re.Equal(61, m.progesses[n].history.Len())
=======
re.Equal(721, m.progresses[n].history.Len())
>>>>>>> 945e29c03 (cluster: dynamic progress time window for offline scene (#7722))
p, ls, cs, err = m.Status(n)
re.NoError(err)
re.Equal(0.7, p)
Expand Down

0 comments on commit 1fbab5c

Please sign in to comment.