This commit is contained in:
Matt Joiner 2015-10-20 17:53:12 +11:00
parent 1a4fbed1ac
commit c7cb1009a5
2 changed files with 12 additions and 5 deletions

View File

@ -109,18 +109,25 @@ func (me data) WriteSectionTo(w io.Writer, off, n int64) (written int64, err err
if err != nil {
return
}
n1, err = io.Copy(w, io.NewSectionReader(f, off, n1))
var w1 int64
w1, err = io.Copy(w, io.NewSectionReader(f, off, n1))
f.Close()
if err != nil {
written += w1
if w1 != n1 {
if err == nil || err == io.EOF {
err = io.ErrUnexpectedEOF
}
return
} else {
err = nil
}
written += n1
off = 0
n -= n1
if n == 0 {
break
return
}
}
err = io.EOF
return
}

View File

@ -673,7 +673,7 @@ func (t *torrent) hashPiece(piece pp.Integer) (ps pieceSum) {
return
}
if n != pl {
panic("lame")
panic(fmt.Sprintf("%T: %d != %d", t.data, n, pl))
}
missinggo.CopyExact(ps[:], hash.Sum(nil))
return