From 862ad66e3bc724abfce972a9d77c1a1ef169d11f Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Tue, 17 Aug 2021 15:01:07 +0300 Subject: [PATCH] change limit priority logic --- server/torr/storage/torrstor/cache.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server/torr/storage/torrstor/cache.go b/server/torr/storage/torrstor/cache.go index e6c9a6d..2686ea8 100644 --- a/server/torr/storage/torrstor/cache.go +++ b/server/torr/storage/torrstor/cache.go @@ -247,12 +247,20 @@ func (c *Cache) getRemPieces() []*Piece { } pc := r.getReaderPiece() end := r.getPiecesRange().End - limit := 5 + limit := 16777216 / c.pieceLength * 5 + if limit > 40 { + limit = 40 + } + count := limit for pc <= end && limit > 0 { if !c.pieces[pc].Complete { if c.torrent.PieceState(pc).Priority == torrent.PiecePriorityNone { - c.torrent.Piece(pc).SetPriority(torrent.PiecePriorityNormal) + if limit > count/2 { + c.torrent.Piece(pc).SetPriority(torrent.PiecePriorityHigh) + } else { + c.torrent.Piece(pc).SetPriority(torrent.PiecePriorityNormal) + } } limit-- }