fix sort/id bug

This commit is contained in:
yourok
2018-12-22 14:33:41 +03:00
parent 4ef644be24
commit 7a11489e3d

View File

@@ -385,16 +385,19 @@ func (t *Torrent) Stats() TorrentStats {
st.ConnectedSeeders = tst.ConnectedSeeders st.ConnectedSeeders = tst.ConnectedSeeders
st.HalfOpenPeers = tst.HalfOpenPeers st.HalfOpenPeers = tst.HalfOpenPeers
for i, f := range t.Files() { files := t.Files()
sort.Slice(files, func(i, j int) bool {
return files[i].Path() < files[j].Path()
})
for i, f := range files {
st.FileStats = append(st.FileStats, TorrentFileStat{ st.FileStats = append(st.FileStats, TorrentFileStat{
Id: i, Id: i,
Path: f.Path(), Path: f.Path(),
Length: f.Length(), Length: f.Length(),
}) })
} }
sort.Slice(st.FileStats, func(i, j int) bool {
return st.FileStats[i].Path < st.FileStats[j].Path
})
} }
return st return st
} }