diff --git a/server/torr/storage/state/state.go b/server/torr/storage/state/state.go index 306c9b0..301c2ed 100644 --- a/server/torr/storage/state/state.go +++ b/server/torr/storage/state/state.go @@ -20,6 +20,7 @@ type ItemState struct { Length int64 Size int64 Completed bool + Priority int } type ReaderState struct { diff --git a/server/torr/storage/torrstor/cache.go b/server/torr/storage/torrstor/cache.go index a6c72b8..187822f 100644 --- a/server/torr/storage/torrstor/cache.go +++ b/server/torr/storage/torrstor/cache.go @@ -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) diff --git a/web/src/components/DialogTorrentDetailsContent/TorrentCache/index.jsx b/web/src/components/DialogTorrentDetailsContent/TorrentCache/index.jsx index fce00ce..d958c46 100644 --- a/web/src/components/DialogTorrentDetailsContent/TorrentCache/index.jsx +++ b/web/src/components/DialogTorrentDetailsContent/TorrentCache/index.jsx @@ -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, ]) diff --git a/web/src/components/DialogTorrentDetailsContent/TorrentCache/snakeSettings.js b/web/src/components/DialogTorrentDetailsContent/TorrentCache/snakeSettings.js index 241c9ec..fcc1d7a 100644 --- a/web/src/components/DialogTorrentDetailsContent/TorrentCache/snakeSettings.js +++ b/web/src/components/DialogTorrentDetailsContent/TorrentCache/snakeSettings.js @@ -48,7 +48,7 @@ export const snakeSettings = { completeColor: '#4db380', backgroundColor: '#dbf2e8', progressColor: '#dbf2e8', - readerColor: '#fff', + readerColor: '#0a0a0a', rangeColor: '#afa6e3', }, }, diff --git a/web/src/components/DialogTorrentDetailsContent/customHooks.jsx b/web/src/components/DialogTorrentDetailsContent/customHooks.jsx index 1f0cf53..28c9536 100644 --- a/web/src/components/DialogTorrentDetailsContent/customHooks.jsx +++ b/web/src/components/DialogTorrentDetailsContent/customHooks.jsx @@ -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