Merge branch 'master' of github.com:anacrolix/torrent

This commit is contained in:
Matt Joiner 2015-10-23 12:38:00 +11:00
commit de69976bbf
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