Skip to content

Commit

Permalink
copy: The return should be done even if ok fail
Browse files Browse the repository at this point in the history
In case of cancellation or a read error, we need to stop the copy. The
condition is wrong as we should return as soon as possible.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
  • Loading branch information
otavio committed Jun 22, 2018
1 parent 4a8800c commit a547f27
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions copy/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ Loop:
case err, ok := <-readErrChan:
if ok {
close(readErrChan)
return false, err
}
case _, ok := <-cancel:
if ok {
return true, nil
}

return false, err
case <-cancel:
return true, nil
case <-time.After(timeout):
finalErr := fmt.Errorf("copy error: timeout")
log.Error(finalErr)
Expand Down

0 comments on commit a547f27

Please sign in to comment.