Update torrent.go

This commit is contained in:
nikk gitanes
2023-10-31 11:51:24 +03:00
parent 9db9bda0c5
commit 6b27c0f4ed

View File

@@ -193,8 +193,8 @@ func (t *Torrent) progressEvent() {
} }
func (t *Torrent) updateRA() { func (t *Torrent) updateRA() {
t.muTorrent.Lock() // t.muTorrent.Lock()
defer t.muTorrent.Unlock() // defer t.muTorrent.Unlock()
// if t.Torrent != nil && t.Torrent.Info() != nil { // if t.Torrent != nil && t.Torrent.Info() != nil {
// pieceLen := t.Torrent.Info().PieceLength // pieceLen := t.Torrent.Info().PieceLength
// adj := pieceLen * int64(t.Torrent.Stats().ActivePeers) / int64(1+t.cache.Readers()) // adj := pieceLen * int64(t.Torrent.Stats().ActivePeers) / int64(1+t.cache.Readers())
@@ -206,14 +206,9 @@ func (t *Torrent) updateRA() {
// } // }
// go t.cache.AdjustRA(adj) // go t.cache.AdjustRA(adj)
// } // }
if t.cache != nil {
readers := t.cache.Readers()
if readers > 0 { // actually it's 0 in preload
adj := int64(16 << 20) // 16 MB fixed RA adj := int64(16 << 20) // 16 MB fixed RA
go t.cache.AdjustRA(adj) go t.cache.AdjustRA(adj)
} }
}
}
func (t *Torrent) expired() bool { func (t *Torrent) expired() bool {
return t.cache.Readers() == 0 && t.expiredTime.Before(time.Now()) && (t.Stat == state.TorrentWorking || t.Stat == state.TorrentClosed) return t.cache.Readers() == 0 && t.expiredTime.Before(time.Now()) && (t.Stat == state.TorrentWorking || t.Stat == state.TorrentClosed)