mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
change load strategy, thx @antibaks
This commit is contained in:
@@ -200,14 +200,26 @@ func (c *Cache) getRemPieces() []*Piece {
|
||||
if p.Size > 0 && !c.isIdInFileBE(ranges, id) {
|
||||
piecesRemove = append(piecesRemove, p)
|
||||
}
|
||||
} else {
|
||||
if c.torrent.PieceState(id).Priority == torrent.PiecePriorityNone {
|
||||
c.torrent.Piece(id).SetPriority(torrent.PiecePriorityNormal)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for r, _ := range c.readers {
|
||||
pc := r.getReaderPiece()
|
||||
end := r.getPiecesRange().End
|
||||
limit := 5
|
||||
|
||||
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)
|
||||
}
|
||||
limit--
|
||||
}
|
||||
pc++
|
||||
}
|
||||
}
|
||||
|
||||
sort.Slice(piecesRemove, func(i, j int) bool {
|
||||
return piecesRemove[i].accessed < piecesRemove[j].accessed
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user