mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 14:56:29 +00:00
backend: Use Get instead of Load for ReaderAt
This commit is contained in:
parent
82d9163955
commit
fc235317fe
@ -9,11 +9,27 @@ type backendReaderAt struct {
|
|||||||
h Handle
|
h Handle
|
||||||
}
|
}
|
||||||
|
|
||||||
func (brd backendReaderAt) ReadAt(p []byte, off int64) (n int, err error) {
|
func (brd backendReaderAt) ReadAt(p []byte, offset int64) (n int, err error) {
|
||||||
return brd.be.Load(brd.h, p, off)
|
return ReadAt(brd.be, brd.h, offset, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReaderAt returns an io.ReaderAt for a file in the backend.
|
// ReaderAt returns an io.ReaderAt for a file in the backend.
|
||||||
func ReaderAt(be Backend, h Handle) io.ReaderAt {
|
func ReaderAt(be Backend, h Handle) io.ReaderAt {
|
||||||
return backendReaderAt{be: be, h: h}
|
return backendReaderAt{be: be, h: h}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadAt reads from the backend handle h at the given position.
|
||||||
|
func ReadAt(be Backend, h Handle, offset int64, p []byte) (n int, err error) {
|
||||||
|
rd, err := be.Get(h, len(p), offset)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
n, err = io.ReadFull(rd, p)
|
||||||
|
e := rd.Close()
|
||||||
|
if err == nil {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user