2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-23 03:18:55 +00:00

Remove backend.Closer, use ioutil.NopCloser() instead

This commit is contained in:
Alexander Neumann 2017-06-15 15:58:23 +02:00
parent aabe2a0a30
commit dd6ce5f9d8
3 changed files with 3 additions and 15 deletions

View File

@ -8,7 +8,6 @@ import (
"restic"
"sync"
"restic/backend"
"restic/errors"
"restic/debug"
@ -114,7 +113,7 @@ func (be *MemoryBackend) Load(ctx context.Context, h restic.Handle, length int,
buf = buf[:length]
}
return backend.Closer{Reader: bytes.NewReader(buf)}, nil
return ioutil.NopCloser(bytes.NewReader(buf)), nil
}
// Stat returns information about a file in the backend.

View File

@ -108,9 +108,8 @@ func (b *restBackend) Save(ctx context.Context, h restic.Handle, rd io.Reader) (
ctx, cancel := context.WithCancel(ctx)
defer cancel()
// make sure that client.Post() cannot close the reader by wrapping it in
// backend.Closer, which has a noop method.
rd = backend.Closer{Reader: rd}
// make sure that client.Post() cannot close the reader by wrapping it
rd = ioutil.NopCloser(rd)
b.sem.GetToken()
resp, err := ctxhttp.Post(ctx, b.client, b.Filename(h), "binary/octet-stream", rd)

View File

@ -29,16 +29,6 @@ func LoadAll(ctx context.Context, be restic.Backend, h restic.Handle) (buf []byt
return ioutil.ReadAll(rd)
}
// Closer wraps an io.Reader and adds a Close() method that does nothing.
type Closer struct {
io.Reader
}
// Close is a no-op.
func (c Closer) Close() error {
return nil
}
// LimitedReadCloser wraps io.LimitedReader and exposes the Close() method.
type LimitedReadCloser struct {
io.ReadCloser