mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 05:26:09 +05:00
expose Peace priority to web
This commit is contained in:
@@ -20,6 +20,7 @@ type ItemState struct {
|
||||
Length int64
|
||||
Size int64
|
||||
Completed bool
|
||||
Priority int
|
||||
}
|
||||
|
||||
type ReaderState struct {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -62,9 +62,10 @@ const TorrentCache = ({ cache, isMini }) => {
|
||||
|
||||
ctx.clearRect(0, 0, canvasWidth, height)
|
||||
|
||||
source.forEach(({ percentage, isReader, isReaderRange }, i) => {
|
||||
source.forEach(({ percentage, priority, isReader, isReaderRange }, i) => {
|
||||
const inProgress = percentage > 0 && percentage < 100
|
||||
const isCompleted = percentage === 100
|
||||
const peacePriority = priority
|
||||
const currentRow = i % piecesInOneRow
|
||||
const currentColumn = Math.floor(i / piecesInOneRow)
|
||||
const fixBlurStroke = borderWidth % 2 === 0 ? 0 : 0.5
|
||||
@@ -90,6 +91,20 @@ const TorrentCache = ({ cache, isMini }) => {
|
||||
ctx.fillRect(0, 0, pieceSize, pieceSize)
|
||||
ctx.strokeRect(0, 0, pieceSize, pieceSize)
|
||||
ctx.setTransform(1, 0, 0, 1, 0, 0)
|
||||
|
||||
if (peacePriority > 0) {
|
||||
let info = ''
|
||||
if (peacePriority === 1) info = '*'
|
||||
else if (peacePriority === 2) info = 'H'
|
||||
else if (peacePriority === 3) info = 'R'
|
||||
else if (peacePriority === 4) info = 'N'
|
||||
else if (peacePriority === 5) info = 'A'
|
||||
ctx.font = isMini ? '12px monospace' : '10px monospace'
|
||||
const xpad = isMini ? pieceSize * 0.34 : pieceSize * 0.28
|
||||
const ypad = isMini ? pieceSize * 0.69 : pieceSize * 0.78
|
||||
ctx.fillStyle = 'black'
|
||||
ctx.fillText(info, x + xpad, y + ypad)
|
||||
}
|
||||
})
|
||||
}, [
|
||||
cacheMap,
|
||||
@@ -107,6 +122,7 @@ const TorrentCache = ({ cache, isMini }) => {
|
||||
completeColor,
|
||||
readerColor,
|
||||
rangeColor,
|
||||
isMini,
|
||||
theme,
|
||||
])
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ export const snakeSettings = {
|
||||
completeColor: '#4db380',
|
||||
backgroundColor: '#dbf2e8',
|
||||
progressColor: '#dbf2e8',
|
||||
readerColor: '#fff',
|
||||
readerColor: '#0a0a0a',
|
||||
rangeColor: '#afa6e3',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -43,9 +43,9 @@ export const useCreateCacheMap = cache => {
|
||||
const map = []
|
||||
|
||||
for (let i = 0; i < PiecesCount; i++) {
|
||||
const { Size, Length } = Pieces[i] || {}
|
||||
const { Size, Length, Priority } = Pieces[i] || {}
|
||||
|
||||
const newPiece = { id: i, percentage: (Size / Length) * 100 || 0 }
|
||||
const newPiece = { id: i, percentage: (Size / Length) * 100 || 0, priority: Priority || 0 }
|
||||
|
||||
Readers.forEach(r => {
|
||||
if (i === r.Reader) newPiece.isReader = true
|
||||
|
||||
Reference in New Issue
Block a user