| 84 | } |
| 85 | |
| 86 | func (r *RetriableReader) Read(b []byte) (int, error) { |
| 87 | n, err := r.reader.Read(b) |
| 88 | |
| 89 | // EOF is a successful response as it is used to signal a graceful end |
| 90 | // of input c.f. https://git.io/v6riQ |
| 91 | // |
| 92 | // Otherwise, if the error is non-nil and already retriable (in the |
| 93 | // case that the underlying reader `r.reader` is itself a |
| 94 | // `*RetriableReader`, return the error wholesale: |
| 95 | if err == nil || err == io.EOF || errors.IsRetriableError(err) { |
| 96 | return n, err |
| 97 | } |
| 98 | |
| 99 | return n, errors.NewRetriableError(err) |
| 100 | } |
| 101 | |
| 102 | // Spool spools the contents from 'from' to 'to' by buffering the entire |
| 103 | // contents of 'from' into a temporary file created in the directory "dir". |