From e551ea25e93aff0d3e8bc169a178a5b562761284 Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Fri, 20 Aug 2021 21:21:21 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BE=D1=87=D0=B5=D1=80=D0=B5=D0=B4=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D1=84=D0=B8=D0=BA=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/torr/storage/torrstor/cache.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/torr/storage/torrstor/cache.go b/server/torr/storage/torrstor/cache.go index a7d8be5..4620798 100644 --- a/server/torr/storage/torrstor/cache.go +++ b/server/torr/storage/torrstor/cache.go @@ -155,7 +155,7 @@ func (c *Cache) GetState() *state.CacheState { } readersState := make([]*state.ReaderState, 0) - + if c.Readers() > 0 { c.muReaders.Lock() for r, _ := range c.readers { @@ -258,13 +258,13 @@ func (c *Cache) getRemPieces() []*Piece { if !c.pieces[i].Complete { if i == readerPos { c.torrent.Piece(i).SetPriority(torrent.PiecePriorityNow) - } else if i == readerPos + 1 { + } else if i == readerPos+1 { c.torrent.Piece(i).SetPriority(torrent.PiecePriorityNext) } else if i > readerPos && i <= readerRAHPos { c.torrent.Piece(i).SetPriority(torrent.PiecePriorityReadahead) - } else if i > readerRAHPos && i <= readerPos + (end - readerPos)/2 && c.torrent.PieceState(i).Priority != torrent.PiecePriorityHigh { + } else if i > readerRAHPos && i <= readerRAHPos+5 && c.torrent.PieceState(i).Priority != torrent.PiecePriorityHigh { c.torrent.Piece(i).SetPriority(torrent.PiecePriorityHigh) - } else if i > readerPos + (end - readerPos)/2 && c.torrent.PieceState(i).Priority != torrent.PiecePriorityNormal { + } else if i > readerRAHPos+5 && c.torrent.PieceState(i).Priority != torrent.PiecePriorityNormal { c.torrent.Piece(i).SetPriority(torrent.PiecePriorityNormal) } limit++ @@ -282,10 +282,10 @@ func (c *Cache) getRemPieces() []*Piece { } func (c *Cache) isIdInFileBE(ranges []Range, id int) bool { - + // keep 8/16 MB FileRangeNotDelete := int64(c.pieceLength) - if (FileRangeNotDelete < 8 * 1024 * 1024) { + if FileRangeNotDelete < 8*1024*1024 { FileRangeNotDelete = 8 * 1024 * 1024 }