From 12e92ae0bdf5b3c9ea1b02ee74f1f61d50d84e3d Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Thu, 20 May 2021 11:12:44 +0300 Subject: [PATCH] fix crash --- server/torr/storage/torrstor/cache.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/torr/storage/torrstor/cache.go b/server/torr/storage/torrstor/cache.go index 3266aa3..2719498 100644 --- a/server/torr/storage/torrstor/cache.go +++ b/server/torr/storage/torrstor/cache.go @@ -300,7 +300,7 @@ func (c *Cache) LoadPiecesOnDisk() { limit := 5 for limit > 0 { - if !c.pieces[pc].Complete { + if c.pieces != nil && c.pieces[pc] != nil && !c.pieces[pc].Complete { if c.torrent.PieceState(pc).Priority == torrent.PiecePriorityNone { c.torrent.Piece(pc).SetPriority(torrent.PiecePriorityNormal) } @@ -314,13 +314,13 @@ func (c *Cache) LoadPiecesOnDisk() { pc := 0 end := c.pieceCount for pc <= end { - if !c.pieces[pc].Complete { + if c.pieces != nil && c.pieces[pc] != nil && !c.pieces[pc].Complete { break } pc++ } for pc <= end && limit > 0 { - if !c.pieces[pc].Complete { + if c.pieces != nil && c.pieces[pc] != nil && !c.pieces[pc].Complete { if c.torrent.PieceState(pc).Priority == torrent.PiecePriorityNone { c.torrent.Piece(pc).SetPriority(torrent.PiecePriorityNormal) }