fix crash

This commit is contained in:
YouROK
2021-05-20 11:12:44 +03:00
parent 7f73c560bd
commit 12e92ae0bd

View File

@@ -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)
}