This commit is contained in:
YouROK
2020-12-07 22:38:36 +03:00
parent 69fc5ae8a3
commit 15d3cf415e
6 changed files with 18 additions and 9 deletions

View File

@@ -56,7 +56,7 @@ func (p *Piece) ReadAt(b []byte, off int64) (n int, err error) {
}
}
if len(p.buffer) < int(off) || len(p.buffer) < int(off)+size {
return 0, io.ErrUnexpectedEOF
return 0, io.EOF
}
n = copy(b, p.buffer[int(off) : int(off)+size][:])
p.accessed = time.Now().Unix()
@@ -66,6 +66,9 @@ func (p *Piece) ReadAt(b []byte, off int64) (n int, err error) {
if int64(len(b))+off >= p.Size {
go p.cache.cleanPieces()
}
if n == 0 && err == nil {
return 0, io.EOF
}
return n, nil
}