mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 14:56:29 +00:00
Merge pull request #397 from restic/remove-readcloser
Remove backend.ReadCloser, this is not used any more
This commit is contained in:
commit
74ce027924
@ -1,21 +0,0 @@
|
||||
package backend
|
||||
|
||||
import "io"
|
||||
|
||||
// ReadCloser wraps a reader and adds a noop Close method if rd does not implement io.Closer.
|
||||
func ReadCloser(rd io.Reader) io.ReadCloser {
|
||||
return readCloser{rd}
|
||||
}
|
||||
|
||||
// readCloser wraps a reader and adds a noop Close method if rd does not implement io.Closer.
|
||||
type readCloser struct {
|
||||
io.Reader
|
||||
}
|
||||
|
||||
func (rd readCloser) Close() error {
|
||||
if r, ok := rd.Reader.(io.Closer); ok {
|
||||
return r.Close()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/restic/restic/crypto"
|
||||
)
|
||||
|
||||
// decryptReadCloser couples an underlying reader with a DecryptReader and
|
||||
// implements io.ReadCloser. On Close(), both readers are closed.
|
||||
type decryptReadCloser struct {
|
||||
r io.ReadCloser
|
||||
dr io.ReadCloser
|
||||
}
|
||||
|
||||
func newDecryptReadCloser(key *crypto.Key, rd io.ReadCloser) (io.ReadCloser, error) {
|
||||
dr, err := crypto.DecryptFrom(key, rd)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &decryptReadCloser{r: rd, dr: dr}, nil
|
||||
}
|
||||
|
||||
func (dr *decryptReadCloser) Read(buf []byte) (int, error) {
|
||||
return dr.dr.Read(buf)
|
||||
}
|
||||
|
||||
func (dr *decryptReadCloser) Close() error {
|
||||
err := dr.dr.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return dr.r.Close()
|
||||
}
|
Loading…
Reference in New Issue
Block a user