expose Peace priority to web

This commit is contained in:
nikk gitanes
2021-08-19 07:24:32 +03:00
parent f2cc860ce5
commit 83d002560b
5 changed files with 23 additions and 5 deletions

View File

@@ -20,6 +20,7 @@ type ItemState struct {
Length int64
Size int64
Completed bool
Priority int
}
type ReaderState struct {

View File

@@ -150,6 +150,7 @@ func (c *Cache) GetState() *state.CacheState {
Size: p.Size,
Length: c.pieceLength,
Completed: p.Complete,
Priority: int(c.torrent.PieceState(p.Id).Priority),
}
}
}
@@ -257,7 +258,7 @@ func (c *Cache) getRemPieces() []*Piece {
for pc <= end && limit > 0 {
if !c.pieces[pc].Complete {
if c.torrent.PieceState(pc).Priority == torrent.PiecePriorityNone {
if limit > count/2 {
if limit < count/2 {
c.torrent.Piece(pc).SetPriority(torrent.PiecePriorityHigh)
} else {
c.torrent.Piece(pc).SetPriority(torrent.PiecePriorityNormal)