Skip to content

Commit

Permalink
handle Read more correctly (#10034)
Browse files Browse the repository at this point in the history
* handle Read more correctly

* similar for Write
  • Loading branch information
zhiqiangxu authored Apr 8, 2024
1 parent 75816d1 commit 9960024
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions op-preimage/filepoller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func (f *FilePoller) Read(b []byte) (int, error) {
return 0, err
}
n, err := f.File.Read(b[read:])
read += n
if errors.Is(err, os.ErrDeadlineExceeded) {
if cerr := f.ctx.Err(); cerr != nil {
return read, cerr
}
} else {
read += n
if read >= len(b) {
return read, err
}
Expand All @@ -50,12 +50,12 @@ func (f *FilePoller) Write(b []byte) (int, error) {
return 0, err
}
n, err := f.File.Write(b[written:])
written += n
if errors.Is(err, os.ErrDeadlineExceeded) {
if cerr := f.ctx.Err(); cerr != nil {
return written, cerr
}
} else {
written += n
if written >= len(b) {
return written, err
}
Expand Down

0 comments on commit 9960024

Please sign in to comment.