From aaaa805183c3958258bd466cf6015388e0262cea Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Sat, 20 Feb 2021 12:37:30 +0300 Subject: [PATCH] change info --- server/torr/torrent.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server/torr/torrent.go b/server/torr/torrent.go index 6f237a3..fa9842a 100644 --- a/server/torr/torrent.go +++ b/server/torr/torrent.go @@ -155,17 +155,17 @@ func (t *Torrent) progressEvent() { t.muTorrent.Lock() if t.Torrent != nil && t.Torrent.Info() != nil { st := t.Torrent.Stats() - deltaDlBytes := st.BytesReadUsefulData.Int64() - t.BytesReadUsefulData - deltaUpBytes := st.BytesWrittenData.Int64() - t.BytesWrittenData + deltaDlBytes := st.BytesRead.Int64() - t.BytesReadUsefulData + deltaUpBytes := st.BytesWritten.Int64() - t.BytesWrittenData deltaTime := time.Since(t.lastTimeSpeed).Seconds() t.DownloadSpeed = float64(deltaDlBytes) / deltaTime t.UploadSpeed = float64(deltaUpBytes) / deltaTime - t.BytesWrittenData = st.BytesWrittenData.Int64() - t.BytesReadUsefulData = st.BytesReadUsefulData.Int64() + t.BytesReadUsefulData = st.BytesRead.Int64() + t.BytesWrittenData = st.BytesWritten.Int64() - t.PreloadedBytes = t.Torrent.BytesCompleted() + t.PreloadedBytes = t.cache.GetState().Filled } else { t.DownloadSpeed = 0 t.UploadSpeed = 0 @@ -288,7 +288,8 @@ func (t *Torrent) Preload(index int, size int64) { if t.Torrent == nil { return } - t.PreloadedBytes = t.Torrent.BytesCompleted() + + t.PreloadedBytes = t.cache.GetState().Filled t.muTorrent.Unlock() stat := fmt.Sprint(file.Torrent().InfoHash().HexString(), " ", utils2.Format(float64(t.PreloadedBytes)), "/", utils2.Format(float64(t.PreloadSize)), " Speed:", utils2.Format(t.DownloadSpeed), " Peers:[", t.Torrent.Stats().ConnectedSeeders, "]", t.Torrent.Stats().ActivePeers, "/", t.Torrent.Stats().TotalPeers)