2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-23 11:28:54 +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" "restic"
"sync" "sync"
"restic/backend"
"restic/errors" "restic/errors"
"restic/debug" "restic/debug"
@ -114,7 +113,7 @@ func (be *MemoryBackend) Load(ctx context.Context, h restic.Handle, length int,
buf = buf[:length] 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. // 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) ctx, cancel := context.WithCancel(ctx)
defer cancel() defer cancel()
// make sure that client.Post() cannot close the reader by wrapping it in // make sure that client.Post() cannot close the reader by wrapping it
// backend.Closer, which has a noop method. rd = ioutil.NopCloser(rd)
rd = backend.Closer{Reader: rd}
b.sem.GetToken() b.sem.GetToken()
resp, err := ctxhttp.Post(ctx, b.client, b.Filename(h), "binary/octet-stream", rd) 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) 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. // LimitedReadCloser wraps io.LimitedReader and exposes the Close() method.
type LimitedReadCloser struct { type LimitedReadCloser struct {
io.ReadCloser io.ReadCloser