From e6a38b1cd194c7c689546f850ef48744ff0318c1 Mon Sep 17 00:00:00 2001 From: Pavel Tatarskiy Date: Fri, 19 May 2023 07:23:34 +0300 Subject: [PATCH] fixes anacrolix/torrent#795 (#807) --- torrent-piece-request-order.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/torrent-piece-request-order.go b/torrent-piece-request-order.go index 17206679..10623da0 100644 --- a/torrent-piece-request-order.go +++ b/torrent-piece-request-order.go @@ -8,9 +8,11 @@ func (t *Torrent) updatePieceRequestOrder(pieceIndex int) { if t.storage == nil { return } - t.cl.pieceRequestOrder[t.clientPieceRequestOrderKey()].Update( - t.pieceRequestOrderKey(pieceIndex), - t.requestStrategyPieceOrderState(pieceIndex)) + if ro, ok := t.cl.pieceRequestOrder[t.clientPieceRequestOrderKey()]; ok { + ro.Update( + t.pieceRequestOrderKey(pieceIndex), + t.requestStrategyPieceOrderState(pieceIndex)) + } } func (t *Torrent) clientPieceRequestOrderKey() interface{} { -- 2.44.0