mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 14:06:44 +08:00
fs: Fix transferTime not being set in JSON logs
This was unintentionally broken in 04aa696
This commit is contained in:
parent
ea4aa696a5
commit
cf5457c2cd
|
@ -313,6 +313,8 @@ func (s *StatsInfo) calculateTransferStats() (ts transferStats) {
|
|||
// we take it off here to avoid double counting
|
||||
ts.totalBytes = s.transferQueueSize + s.bytes + transferringBytesTotal - transferringBytesDone
|
||||
ts.speed = s.average.speed
|
||||
dt := s.totalDuration()
|
||||
ts.transferTime = dt.Seconds()
|
||||
|
||||
return ts
|
||||
}
|
||||
|
|
|
@ -251,6 +251,28 @@ func TestStatsTotalDuration(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestRemoteStats(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
startTime := time.Now()
|
||||
time1 := startTime.Add(-40 * time.Second)
|
||||
time2 := time1.Add(10 * time.Second)
|
||||
|
||||
t.Run("Single completed transfer", func(t *testing.T) {
|
||||
s := NewStats(ctx)
|
||||
tr1 := &Transfer{
|
||||
startedAt: time1,
|
||||
completedAt: time2,
|
||||
}
|
||||
s.AddTransfer(tr1)
|
||||
time.Sleep(time.Millisecond)
|
||||
rs, err := s.RemoteStats()
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, float64(10), rs["transferTime"])
|
||||
assert.Greater(t, rs["elapsedTime"], float64(0))
|
||||
})
|
||||
}
|
||||
|
||||
// make time ranges from string description for testing
|
||||
func makeTimeRanges(t *testing.T, in []string) timeRanges {
|
||||
trs := make(timeRanges, len(in))
|
||||
|
|
Loading…
Reference in New Issue
Block a user