update reader to use ReadAtLeast
This commit is contained in:
parent
2562f2e9a6
commit
c12d802811
4
extern/sector-storage/fr32/readers.go
vendored
4
extern/sector-storage/fr32/readers.go
vendored
@ -51,13 +51,13 @@ func (r *unpadReader) Read(out []byte) (int, error) {
|
|||||||
|
|
||||||
r.left -= uint64(todo)
|
r.left -= uint64(todo)
|
||||||
|
|
||||||
n, err := r.src.Read(r.work[:todo])
|
n, err := io.ReadAtLeast(r.src, r.work[:todo], int(todo))
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if n != int(todo) {
|
if n != int(todo) {
|
||||||
return 0, xerrors.Errorf("didn't read enough: %w", err)
|
return 0, xerrors.Errorf("didn't read enough: %d / %d, left %d, out %d", n, todo, r.left, len(out))
|
||||||
}
|
}
|
||||||
|
|
||||||
Unpad(r.work[:todo], out[:todo.Unpadded()])
|
Unpad(r.work[:todo], out[:todo.Unpadded()])
|
||||||
|
Loading…
Reference in New Issue
Block a user