rc: fix speed does not update in core/stats

This commit is contained in:
negative0 2021-08-14 10:26:39 +05:30 committed by Nick Craig-Wood
parent 448a03181f
commit 82ad9a30b9
2 changed files with 4 additions and 0 deletions

View File

@ -375,6 +375,9 @@ func (sg *statsGroups) sum(ctx context.Context) *StatsInfo {
sum.startedTransfers = append(sum.startedTransfers, stats.startedTransfers...)
sum.oldDuration += stats.oldDuration
sum.oldTimeRanges = append(sum.oldTimeRanges, stats.oldTimeRanges...)
stats.average.mu.Lock()
sum.average.speed += stats.average.speed
stats.average.mu.Unlock()
}
stats.mu.RUnlock()
}

View File

@ -62,6 +62,7 @@ func TestStatsGroupOperations(t *testing.T) {
assert.Equal(t, stats1.bytes+stats2.bytes, sum.bytes)
assert.Equal(t, stats1.errors+stats2.errors, sum.errors)
assert.Equal(t, stats1.oldDuration+stats2.oldDuration, sum.oldDuration)
assert.Equal(t, stats1.average.speed+stats2.average.speed, sum.average.speed)
// dict can iterate in either order
a := timeRanges{stats1.oldTimeRanges[0], stats2.oldTimeRanges[0]}
b := timeRanges{stats2.oldTimeRanges[0], stats1.oldTimeRanges[0]}