Skip to content

Commit

Permalink
In progress.Reader emit final report on EOF.
Browse files Browse the repository at this point in the history
  • Loading branch information
wupeka committed Mar 6, 2018
1 parent d4e405e commit 1620160
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# changelog

* In progress.Reader emit final report on EOF.

### 0.17.0 (2018-02-28)

* Add HostStorageSystem.AttachScsiLun method
Expand Down
5 changes: 3 additions & 2 deletions vim25/progress/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,12 @@ func NewReader(ctx context.Context, s Sinker, r io.Reader, size int64) *reader {
// underlying channel.
func (r *reader) Read(b []byte) (int, error) {
n, err := r.r.Read(b)
if err != nil {
r.pos += int64(n)

if err != nil && err != io.EOF {
return n, err
}

r.pos += int64(n)
q := readerReport{
t: time.Now(),
pos: r.pos,
Expand Down
1 change: 1 addition & 0 deletions vim25/progress/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func TestReader(t *testing.T) {

// Read EOF
_, err = pr.Read(buf[:])
q = <-ch
if err != io.EOF {
t.Errorf("Expected io.EOF, but got: %s", err)
}
Expand Down

0 comments on commit 1620160

Please sign in to comment.