mirror of
https://github.com/rclone/rclone.git
synced 2024-11-26 02:14:42 +01:00
accounting: stabilize display order of transfers on Windows
Before this change we sorted transfers in the stats list solely on time started. However if --check-first was in use then lots of transfers could be started in the same millisecond. Because Windows time resolution is only 1mS this caused the entries to sort equal and bounce around in the list. This change fixes the sort so that if the time is equal it uses the name which should stabilize the order. Fixes #4599
This commit is contained in:
parent
ab88a3341f
commit
433b73a5a8
@ -72,8 +72,16 @@ func (tm *transferMap) _sortedSlice() []*Transfer {
|
||||
for _, tr := range tm.items {
|
||||
s = append(s, tr)
|
||||
}
|
||||
// sort by time first and if equal by name. Note that the relatively
|
||||
// low time resolution on Windows can cause equal times.
|
||||
sort.Slice(s, func(i, j int) bool {
|
||||
return s[i].startedAt.Before(s[j].startedAt)
|
||||
a, b := s[i], s[j]
|
||||
if a.startedAt.Before(b.startedAt) {
|
||||
return true
|
||||
} else if !a.startedAt.Equal(b.startedAt) {
|
||||
return false
|
||||
}
|
||||
return a.remote < b.remote
|
||||
})
|
||||
return s
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user