mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
improve priority logic
This commit is contained in:
@@ -247,7 +247,7 @@ func (c *Cache) getRemPieces() []*Piece {
|
|||||||
}
|
}
|
||||||
pc := r.getReaderPiece()
|
pc := r.getReaderPiece()
|
||||||
end := r.getPiecesRange().End
|
end := r.getPiecesRange().End
|
||||||
limit := 16777216 / c.pieceLength * 5
|
limit := 16777216 / c.pieceLength * 5 // 80 MB
|
||||||
if limit > 40 {
|
if limit > 40 {
|
||||||
limit = 40
|
limit = 40
|
||||||
}
|
}
|
||||||
@@ -256,7 +256,11 @@ func (c *Cache) getRemPieces() []*Piece {
|
|||||||
for pc <= end && limit > 0 {
|
for pc <= end && limit > 0 {
|
||||||
if !c.pieces[pc].Complete {
|
if !c.pieces[pc].Complete {
|
||||||
if c.torrent.PieceState(pc).Priority == torrent.PiecePriorityNone {
|
if c.torrent.PieceState(pc).Priority == torrent.PiecePriorityNone {
|
||||||
if limit > count/2 {
|
if limit = 1 {
|
||||||
|
c.torrent.Piece(pc).SetPriority(torrent.PiecePriorityNext)
|
||||||
|
} else if limit < 4 {
|
||||||
|
c.torrent.Piece(pc).SetPriority(torrent.PiecePriorityReadahead)
|
||||||
|
} else if limit < count/2 {
|
||||||
c.torrent.Piece(pc).SetPriority(torrent.PiecePriorityHigh)
|
c.torrent.Piece(pc).SetPriority(torrent.PiecePriorityHigh)
|
||||||
} else {
|
} else {
|
||||||
c.torrent.Piece(pc).SetPriority(torrent.PiecePriorityNormal)
|
c.torrent.Piece(pc).SetPriority(torrent.PiecePriorityNormal)
|
||||||
|
|||||||
Reference in New Issue
Block a user