mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 22:27:35 +00:00
backend: rename LimitReader to LimitReadCloser
This commit is contained in:
parent
0ca678228d
commit
1f94ac724f
@ -100,7 +100,7 @@ outer:
|
||||
|
||||
// wrap around io.LimitedReader that implements io.ReadCloser
|
||||
type blobReader struct {
|
||||
f io.Closer
|
||||
cl io.Closer
|
||||
rd io.Reader
|
||||
closed bool
|
||||
}
|
||||
@ -120,7 +120,7 @@ func (l *blobReader) Close() error {
|
||||
}
|
||||
|
||||
if !l.closed {
|
||||
err := l.f.Close()
|
||||
err := l.cl.Close()
|
||||
l.closed = true
|
||||
return err
|
||||
}
|
||||
@ -128,6 +128,8 @@ func (l *blobReader) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func LimitReader(f io.ReadCloser, n int64) *blobReader {
|
||||
return &blobReader{f: f, rd: io.LimitReader(f, n)}
|
||||
// LimitReadCloser returns a new reader wraps r in an io.LimitReader, but also
|
||||
// implements the Close() method.
|
||||
func LimitReadCloser(r io.ReadCloser, n int64) *blobReader {
|
||||
return &blobReader{cl: r, rd: io.LimitReader(r, n)}
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ func (b *Local) GetReader(t backend.Type, name string, offset, length uint) (io.
|
||||
return f, nil
|
||||
}
|
||||
|
||||
return backend.LimitReader(f, int64(length)), nil
|
||||
return backend.LimitReadCloser(f, int64(length)), nil
|
||||
}
|
||||
|
||||
// Test returns true if a blob of the given type and name exists in the backend.
|
||||
|
@ -446,7 +446,7 @@ func (r *SFTP) GetReader(t backend.Type, name string, offset, length uint) (io.R
|
||||
return f, nil
|
||||
}
|
||||
|
||||
return backend.LimitReader(f, int64(length)), nil
|
||||
return backend.LimitReadCloser(f, int64(length)), nil
|
||||
}
|
||||
|
||||
// Test returns true if a blob of the given type and name exists in the backend.
|
||||
|
Loading…
Reference in New Issue
Block a user