]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Improve hash piece error logging
authorMatt Joiner <anacrolix@gmail.com>
Wed, 8 Jan 2020 22:51:36 +0000 (09:51 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 13 Jan 2020 23:51:09 +0000 (10:51 +1100)
torrent.go

index 51ef3681166a64f6e89be66cf4119ab79a8f9304..caeb8c234104f17350f82ad3346b65ed8b09b19e 100644 (file)
@@ -749,7 +749,7 @@ func (t *Torrent) hashPiece(piece pieceIndex) (ret metainfo.Hash, copyErr error)
        p.waitNoPendingWrites()
        ip := t.info.Piece(int(piece))
        pl := ip.Length()
-       _, copyErr = io.CopyN(hash, io.NewSectionReader(t.pieces[piece].Storage(), 0, pl), pl)
+       _, copyErr = io.Copy(hash, io.NewSectionReader(t.pieces[piece].Storage(), 0, pl))
        missinggo.CopyExact(&ret, hash.Sum(nil))
        return
 }
@@ -1658,7 +1658,7 @@ func (t *Torrent) pieceHasher(index pieceIndex) {
        sum, copyErr := t.hashPiece(index)
        correct := sum == *p.hash
        if !correct {
-               log.Fmsg("piece %v hash failure copy error: %v", index, copyErr).Log(t.logger)
+               log.Fmsg("piece %v (%s) hash failure copy error: %v", p, p.hash.HexString(), copyErr).Log(t.logger)
        }
        t.storageLock.RUnlock()
        t.cl.lock()