Skip to content

Commit

Permalink
Expose the underlying ReadCloser during restore (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncabatoff committed Apr 27, 2022
1 parent 1b44a7b commit 7fc5a41
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions progress.go
Expand Up @@ -119,12 +119,28 @@ func newCountingReader(r io.Reader) *countingReader {

type countingReadCloser struct {
*countingReader
io.Closer
readCloser io.ReadCloser
}

func newCountingReadCloser(rc io.ReadCloser) *countingReadCloser {
return &countingReadCloser{
countingReader: newCountingReader(rc),
Closer: rc,
readCloser: rc,
}
}

func (c countingReadCloser) Close() error {
return c.readCloser.Close()
}

func (c countingReadCloser) WrappedReadCloser() io.ReadCloser {
return c.readCloser
}

// ReadCloserWrapper allows access to an underlying ReadCloser from a wrapper.
type ReadCloserWrapper interface {
io.ReadCloser
WrappedReadCloser() io.ReadCloser
}

var _ ReadCloserWrapper = &countingReadCloser{}

0 comments on commit 7fc5a41

Please sign in to comment.