mirror of
https://github.com/rclone/rclone.git
synced 2025-08-09 13:55:15 +02:00
accounting: allow up to 100 completed transfers in the accounting list
This fixes the core/transfers rc so it shows items again.
This commit is contained in:
@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/fs/fserrors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -306,3 +307,30 @@ func TestTimeRangeDuration(t *testing.T) {
|
||||
assert.Equal(t, 1*time.Second, makeTimeRanges(t, []string{"1-2"}).total())
|
||||
assert.Equal(t, 91*time.Second, makeTimeRanges(t, []string{"1-2", "10-100"}).total())
|
||||
}
|
||||
|
||||
func TestPruneTransfers(t *testing.T) {
|
||||
max := maxCompletedTransfers + fs.Config.Transfers
|
||||
|
||||
s := NewStats()
|
||||
for i := int64(1); i <= int64(max+100); i++ {
|
||||
s.AddTransfer(&Transfer{
|
||||
startedAt: time.Unix(i, 0),
|
||||
completedAt: time.Unix(i+1, 0),
|
||||
})
|
||||
}
|
||||
|
||||
s.mu.Lock()
|
||||
assert.Equal(t, time.Duration(max+100)*time.Second, s.totalDuration())
|
||||
assert.Equal(t, max+100, len(s.startedTransfers))
|
||||
s.mu.Unlock()
|
||||
|
||||
for i := 0; i < 200; i++ {
|
||||
s.PruneTransfers()
|
||||
}
|
||||
|
||||
s.mu.Lock()
|
||||
assert.Equal(t, time.Duration(max+100)*time.Second, s.totalDuration())
|
||||
assert.Equal(t, max, len(s.startedTransfers))
|
||||
s.mu.Unlock()
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user