mirror of
https://github.com/restic/restic.git
synced 2025-12-04 00:21:46 +00:00
Add nil-receiver awareness to all Reader/Writer
This commit is contained in:
@@ -115,6 +115,10 @@ func (l *blobReader) Read(p []byte) (int, error) {
|
||||
}
|
||||
|
||||
func (l *blobReader) Close() error {
|
||||
if l == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !l.closed {
|
||||
err := l.f.Close()
|
||||
l.closed = true
|
||||
|
||||
@@ -554,6 +554,10 @@ func (r *SFTP) ID() string {
|
||||
|
||||
// Close closes the sftp connection and terminates the underlying command.
|
||||
func (s *SFTP) Close() error {
|
||||
if s == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
s.c.Close()
|
||||
// TODO: add timeout after which the process is killed
|
||||
return s.cmd.Wait()
|
||||
|
||||
@@ -24,6 +24,10 @@ func NewHashAppendWriter(w io.Writer, h hash.Hash) *HashAppendWriter {
|
||||
}
|
||||
|
||||
func (h *HashAppendWriter) Close() error {
|
||||
if h == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !h.closed {
|
||||
h.closed = true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user