report io.EOF in Read() to caller

This commit is contained in:
Hanno Hecker 2016-01-06 20:32:13 +01:00
parent 4dfd3d7373
commit 0d31cf4b25
1 changed files with 5 additions and 1 deletions

View File

@ -103,7 +103,11 @@ func (f *UnionFile) Read(s []byte) (int, error) {
if (err == nil || err == io.EOF) && f.base != nil { if (err == nil || err == io.EOF) && f.base != nil {
// advance the file position also in the base file, the next // advance the file position also in the base file, the next
// call may be a write at this position (or a seek with SEEK_CUR) // call may be a write at this position (or a seek with SEEK_CUR)
_, err = f.base.Seek(int64(n), os.SEEK_CUR) if _, seekErr := f.base.Seek(int64(n), os.SEEK_CUR); serr != nil {
// only overwrite err in case the seek fails: we need to
// report an eventual io.EOF to the caller
err = seekErr
}
} }
return n, err return n, err
} }