diff --git a/src/restic/archiver/archiver_duplication_test.go b/src/restic/archiver/archiver_duplication_test.go index 43baf011d..9e946b37e 100644 --- a/src/restic/archiver/archiver_duplication_test.go +++ b/src/restic/archiver/archiver_duplication_test.go @@ -43,7 +43,7 @@ func forgetfulBackend() restic.Backend { return false, nil } - be.GetFn = func(h restic.Handle, length int, offset int64) (io.ReadCloser, error) { + be.LoadFn = func(h restic.Handle, length int, offset int64) (io.ReadCloser, error) { return nil, errors.New("not found") } diff --git a/src/restic/backend.go b/src/restic/backend.go index ca2eb73d3..0db225d59 100644 --- a/src/restic/backend.go +++ b/src/restic/backend.go @@ -20,11 +20,11 @@ type Backend interface { // Save stores the data in the backend under the given handle. Save(h Handle, rd io.Reader) error - // Get returns a reader that yields the contents of the file at h at the + // Load returns a reader that yields the contents of the file at h at the // given offset. If length is larger than zero, only a portion of the file // is returned. rd must be closed after use. If an error is returned, the // ReadCloser must be nil. - Get(h Handle, length int, offset int64) (io.ReadCloser, error) + Load(h Handle, length int, offset int64) (io.ReadCloser, error) // Stat returns information about the File identified by h. Stat(h Handle) (FileInfo, error) diff --git a/src/restic/backend/local/backend_test.go b/src/restic/backend/local/backend_test.go index e7efedb57..8607f01b7 100644 --- a/src/restic/backend/local/backend_test.go +++ b/src/restic/backend/local/backend_test.go @@ -44,11 +44,11 @@ func TestLocalBackendConfig(t *testing.T) { test.TestConfig(t) } -func TestLocalBackendGet(t *testing.T) { +func TestLocalBackendLoad(t *testing.T) { if SkipMessage != "" { t.Skip(SkipMessage) } - test.TestGet(t) + test.TestLoad(t) } func TestLocalBackendSave(t *testing.T) { diff --git a/src/restic/backend/local/local.go b/src/restic/backend/local/local.go index 4698c8d43..4f7dbfdb8 100644 --- a/src/restic/backend/local/local.go +++ b/src/restic/backend/local/local.go @@ -170,11 +170,11 @@ func (b *Local) Save(h restic.Handle, rd io.Reader) (err error) { return setNewFileMode(filename, fi) } -// Get returns a reader that yields the contents of the file at h at the +// Load returns a reader that yields the contents of the file at h at the // given offset. If length is nonzero, only a portion of the file is // returned. rd must be closed after use. -func (b *Local) Get(h restic.Handle, length int, offset int64) (io.ReadCloser, error) { - debug.Log("Get %v, length %v, offset %v", h, length, offset) +func (b *Local) Load(h restic.Handle, length int, offset int64) (io.ReadCloser, error) { + debug.Log("Load %v, length %v, offset %v", h, length, offset) if err := h.Valid(); err != nil { return nil, err } diff --git a/src/restic/backend/mem/backend_test.go b/src/restic/backend/mem/backend_test.go index 7fda28128..13e95f115 100644 --- a/src/restic/backend/mem/backend_test.go +++ b/src/restic/backend/mem/backend_test.go @@ -44,11 +44,11 @@ func TestMemBackendConfig(t *testing.T) { test.TestConfig(t) } -func TestMemBackendGet(t *testing.T) { +func TestMemBackendLoad(t *testing.T) { if SkipMessage != "" { t.Skip(SkipMessage) } - test.TestGet(t) + test.TestLoad(t) } func TestMemBackendSave(t *testing.T) { diff --git a/src/restic/backend/mem/mem_backend.go b/src/restic/backend/mem/mem_backend.go index ec13e4321..76a00b7fe 100644 --- a/src/restic/backend/mem/mem_backend.go +++ b/src/restic/backend/mem/mem_backend.go @@ -83,10 +83,10 @@ func (be *MemoryBackend) Save(h restic.Handle, rd io.Reader) error { return nil } -// Get returns a reader that yields the contents of the file at h at the +// Load returns a reader that yields the contents of the file at h at the // given offset. If length is nonzero, only a portion of the file is // returned. rd must be closed after use. -func (be *MemoryBackend) Get(h restic.Handle, length int, offset int64) (io.ReadCloser, error) { +func (be *MemoryBackend) Load(h restic.Handle, length int, offset int64) (io.ReadCloser, error) { if err := h.Valid(); err != nil { return nil, err } @@ -98,7 +98,7 @@ func (be *MemoryBackend) Get(h restic.Handle, length int, offset int64) (io.Read h.Name = "" } - debug.Log("Get %v offset %v len %v", h, offset, length) + debug.Log("Load %v offset %v len %v", h, offset, length) if offset < 0 { return nil, errors.New("offset is negative") diff --git a/src/restic/backend/rest/backend_test.go b/src/restic/backend/rest/backend_test.go index 936076f89..4274bfcb1 100644 --- a/src/restic/backend/rest/backend_test.go +++ b/src/restic/backend/rest/backend_test.go @@ -44,11 +44,11 @@ func TestRestBackendConfig(t *testing.T) { test.TestConfig(t) } -func TestRestBackendGet(t *testing.T) { +func TestRestBackendLoad(t *testing.T) { if SkipMessage != "" { t.Skip(SkipMessage) } - test.TestGet(t) + test.TestLoad(t) } func TestRestBackendSave(t *testing.T) { diff --git a/src/restic/backend/rest/rest.go b/src/restic/backend/rest/rest.go index cf28dcad4..6ed05965f 100644 --- a/src/restic/backend/rest/rest.go +++ b/src/restic/backend/rest/rest.go @@ -106,11 +106,11 @@ func (b *restBackend) Save(h restic.Handle, rd io.Reader) (err error) { return nil } -// Get returns a reader that yields the contents of the file at h at the +// Load returns a reader that yields the contents of the file at h at the // given offset. If length is nonzero, only a portion of the file is // returned. rd must be closed after use. -func (b *restBackend) Get(h restic.Handle, length int, offset int64) (io.ReadCloser, error) { - debug.Log("Get %v, length %v, offset %v", h, length, offset) +func (b *restBackend) Load(h restic.Handle, length int, offset int64) (io.ReadCloser, error) { + debug.Log("Load %v, length %v, offset %v", h, length, offset) if err := h.Valid(); err != nil { return nil, err } @@ -133,7 +133,7 @@ func (b *restBackend) Get(h restic.Handle, length int, offset int64) (io.ReadClo byteRange = fmt.Sprintf("bytes=%d-%d", offset, offset+int64(length)-1) } req.Header.Add("Range", byteRange) - debug.Log("Get(%v) send range %v", h, byteRange) + debug.Log("Load(%v) send range %v", h, byteRange) <-b.connChan resp, err := b.client.Do(req) diff --git a/src/restic/backend/s3/backend_test.go b/src/restic/backend/s3/backend_test.go index 44d8b6377..82eca2631 100644 --- a/src/restic/backend/s3/backend_test.go +++ b/src/restic/backend/s3/backend_test.go @@ -44,11 +44,11 @@ func TestS3BackendConfig(t *testing.T) { test.TestConfig(t) } -func TestS3BackendGet(t *testing.T) { +func TestS3BackendLoad(t *testing.T) { if SkipMessage != "" { t.Skip(SkipMessage) } - test.TestGet(t) + test.TestLoad(t) } func TestS3BackendSave(t *testing.T) { diff --git a/src/restic/backend/s3/s3.go b/src/restic/backend/s3/s3.go index b9bd28033..00ca758eb 100644 --- a/src/restic/backend/s3/s3.go +++ b/src/restic/backend/s3/s3.go @@ -104,11 +104,11 @@ func (be *s3) Save(h restic.Handle, rd io.Reader) (err error) { return errors.Wrap(err, "client.PutObject") } -// Get returns a reader that yields the contents of the file at h at the +// Load returns a reader that yields the contents of the file at h at the // given offset. If length is nonzero, only a portion of the file is // returned. rd must be closed after use. -func (be *s3) Get(h restic.Handle, length int, offset int64) (io.ReadCloser, error) { - debug.Log("Get %v, length %v, offset %v", h, length, offset) +func (be *s3) Load(h restic.Handle, length int, offset int64) (io.ReadCloser, error) { + debug.Log("Load %v, length %v, offset %v", h, length, offset) if err := h.Valid(); err != nil { return nil, err } @@ -138,7 +138,7 @@ func (be *s3) Get(h restic.Handle, length int, offset int64) (io.ReadCloser, err // if we're going to read the whole object, just pass it on. if length == 0 { - debug.Log("Get %v: pass on object", h) + debug.Log("Load %v: pass on object", h) _, err = obj.Seek(offset, 0) if err != nil { _ = obj.Close() @@ -167,9 +167,9 @@ func (be *s3) Get(h restic.Handle, length int, offset int64) (io.ReadCloser, err buf := make([]byte, l) n, err := obj.ReadAt(buf, offset) - debug.Log("Get %v: use buffer with ReadAt: %v, %v", h, n, err) + debug.Log("Load %v: use buffer with ReadAt: %v, %v", h, n, err) if err == io.EOF { - debug.Log("Get %v: shorten buffer %v -> %v", h, len(buf), n) + debug.Log("Load %v: shorten buffer %v -> %v", h, len(buf), n) buf = buf[:n] err = nil } diff --git a/src/restic/backend/sftp/backend_test.go b/src/restic/backend/sftp/backend_test.go index 8ff93b124..a812f8cd0 100644 --- a/src/restic/backend/sftp/backend_test.go +++ b/src/restic/backend/sftp/backend_test.go @@ -44,11 +44,11 @@ func TestSftpBackendConfig(t *testing.T) { test.TestConfig(t) } -func TestSftpBackendGet(t *testing.T) { +func TestSftpBackendLoad(t *testing.T) { if SkipMessage != "" { t.Skip(SkipMessage) } - test.TestGet(t) + test.TestLoad(t) } func TestSftpBackendSave(t *testing.T) { diff --git a/src/restic/backend/sftp/sftp.go b/src/restic/backend/sftp/sftp.go index 8485ad8e4..b7f0922b6 100644 --- a/src/restic/backend/sftp/sftp.go +++ b/src/restic/backend/sftp/sftp.go @@ -360,11 +360,11 @@ func (r *SFTP) Save(h restic.Handle, rd io.Reader) (err error) { return err } -// Get returns a reader that yields the contents of the file at h at the +// Load returns a reader that yields the contents of the file at h at the // given offset. If length is nonzero, only a portion of the file is // returned. rd must be closed after use. -func (r *SFTP) Get(h restic.Handle, length int, offset int64) (io.ReadCloser, error) { - debug.Log("Get %v, length %v, offset %v", h, length, offset) +func (r *SFTP) Load(h restic.Handle, length int, offset int64) (io.ReadCloser, error) { + debug.Log("Load %v, length %v, offset %v", h, length, offset) if err := h.Valid(); err != nil { return nil, err } diff --git a/src/restic/backend/test/backend_test.go b/src/restic/backend/test/backend_test.go index 6ea08c882..b495ce663 100644 --- a/src/restic/backend/test/backend_test.go +++ b/src/restic/backend/test/backend_test.go @@ -44,11 +44,11 @@ func TestTestBackendConfig(t *testing.T) { test.TestConfig(t) } -func TestTestBackendGet(t *testing.T) { +func TestTestBackendLoad(t *testing.T) { if SkipMessage != "" { t.Skip(SkipMessage) } - test.TestGet(t) + test.TestLoad(t) } func TestTestBackendSave(t *testing.T) { diff --git a/src/restic/backend/test/tests.go b/src/restic/backend/test/tests.go index 9027c12e4..54583b0ce 100644 --- a/src/restic/backend/test/tests.go +++ b/src/restic/backend/test/tests.go @@ -178,19 +178,19 @@ func TestConfig(t testing.TB) { } } -// TestGet tests the backend's Get function. -func TestGet(t testing.TB) { +// TestLoad tests the backend's Load function. +func TestLoad(t testing.TB) { b := open(t) defer close(t) - _, err := b.Get(restic.Handle{}, 0, 0) + _, err := b.Load(restic.Handle{}, 0, 0) if err == nil { - t.Fatalf("Get() did not return an error for invalid handle") + t.Fatalf("Load() did not return an error for invalid handle") } - _, err = b.Get(restic.Handle{Type: restic.DataFile, Name: "foobar"}, 0, 0) + _, err = b.Load(restic.Handle{Type: restic.DataFile, Name: "foobar"}, 0, 0) if err == nil { - t.Fatalf("Get() did not return an error for non-existing blob") + t.Fatalf("Load() did not return an error for non-existing blob") } length := rand.Intn(1<<24) + 2000 @@ -204,13 +204,13 @@ func TestGet(t testing.TB) { t.Fatalf("Save() error: %v", err) } - rd, err := b.Get(handle, 100, -1) + rd, err := b.Load(handle, 100, -1) if err == nil { - t.Fatalf("Get() returned no error for negative offset!") + t.Fatalf("Load() returned no error for negative offset!") } if rd != nil { - t.Fatalf("Get() returned a non-nil reader for negative offset!") + t.Fatalf("Load() returned a non-nil reader for negative offset!") } for i := 0; i < 50; i++ { @@ -234,36 +234,36 @@ func TestGet(t testing.TB) { d = d[:l] } - rd, err := b.Get(handle, getlen, int64(o)) + rd, err := b.Load(handle, getlen, int64(o)) if err != nil { - t.Errorf("Get(%d, %d) returned unexpected error: %v", l, o, err) + t.Errorf("Load(%d, %d) returned unexpected error: %v", l, o, err) continue } buf, err := ioutil.ReadAll(rd) if err != nil { - t.Errorf("Get(%d, %d) ReadAll() returned unexpected error: %v", l, o, err) + t.Errorf("Load(%d, %d) ReadAll() returned unexpected error: %v", l, o, err) continue } if l <= len(d) && len(buf) != l { - t.Errorf("Get(%d, %d) wrong number of bytes read: want %d, got %d", l, o, l, len(buf)) + t.Errorf("Load(%d, %d) wrong number of bytes read: want %d, got %d", l, o, l, len(buf)) continue } if l > len(d) && len(buf) != len(d) { - t.Errorf("Get(%d, %d) wrong number of bytes read for overlong read: want %d, got %d", l, o, l, len(buf)) + t.Errorf("Load(%d, %d) wrong number of bytes read for overlong read: want %d, got %d", l, o, l, len(buf)) continue } if !bytes.Equal(buf, d) { - t.Errorf("Get(%d, %d) returned wrong bytes", l, o) + t.Errorf("Load(%d, %d) returned wrong bytes", l, o) continue } err = rd.Close() if err != nil { - t.Errorf("Get(%d, %d) rd.Close() returned unexpected error: %v", l, o, err) + t.Errorf("Load(%d, %d) rd.Close() returned unexpected error: %v", l, o, err) continue } } @@ -398,7 +398,7 @@ func TestBackend(t testing.TB) { test.Assert(t, err != nil, "blob data could be extracted before creation") // try to read not existing blob - _, err = b.Get(h, 0, 0) + _, err = b.Load(h, 0, 0) test.Assert(t, err != nil, "blob reader could be obtained before creation") // try to get string out, should fail @@ -423,7 +423,7 @@ func TestBackend(t testing.TB) { length := end - start buf2 := make([]byte, length) - rd, err := b.Get(h, len(buf2), int64(start)) + rd, err := b.Load(h, len(buf2), int64(start)) test.OK(t, err) n, err := io.ReadFull(rd, buf2) test.OK(t, err) diff --git a/src/restic/backend/utils.go b/src/restic/backend/utils.go index 0af9486ba..27d2b9ad5 100644 --- a/src/restic/backend/utils.go +++ b/src/restic/backend/utils.go @@ -8,7 +8,7 @@ import ( // LoadAll reads all data stored in the backend for the handle. func LoadAll(be restic.Backend, h restic.Handle) (buf []byte, err error) { - rd, err := be.Get(h, 0, 0) + rd, err := be.Load(h, 0, 0) if err != nil { return nil, err } diff --git a/src/restic/checker/checker_test.go b/src/restic/checker/checker_test.go index c1df97072..bdd611471 100644 --- a/src/restic/checker/checker_test.go +++ b/src/restic/checker/checker_test.go @@ -209,8 +209,8 @@ type errorBackend struct { ProduceErrors bool } -func (b errorBackend) Get(h restic.Handle, length int, offset int64) (io.ReadCloser, error) { - rd, err := b.Backend.Get(h, length, offset) +func (b errorBackend) Load(h restic.Handle, length int, offset int64) (io.ReadCloser, error) { + rd, err := b.Backend.Load(h, length, offset) if err != nil { return rd, err } diff --git a/src/restic/mock/backend.go b/src/restic/mock/backend.go index fbbc9e658..9c5504f1a 100644 --- a/src/restic/mock/backend.go +++ b/src/restic/mock/backend.go @@ -11,7 +11,7 @@ import ( type Backend struct { CloseFn func() error SaveFn func(h restic.Handle, rd io.Reader) error - GetFn func(h restic.Handle, length int, offset int64) (io.ReadCloser, error) + LoadFn func(h restic.Handle, length int, offset int64) (io.ReadCloser, error) StatFn func(h restic.Handle) (restic.FileInfo, error) ListFn func(restic.FileType, <-chan struct{}) <-chan string RemoveFn func(restic.FileType, string) error @@ -47,13 +47,13 @@ func (m *Backend) Save(h restic.Handle, rd io.Reader) error { return m.SaveFn(h, rd) } -// Get loads data from the backend. -func (m *Backend) Get(h restic.Handle, length int, offset int64) (io.ReadCloser, error) { - if m.GetFn == nil { +// Load loads data from the backend. +func (m *Backend) Load(h restic.Handle, length int, offset int64) (io.ReadCloser, error) { + if m.LoadFn == nil { return nil, errors.New("not implemented") } - return m.GetFn(h, length, offset) + return m.LoadFn(h, length, offset) } // Stat an object in the backend. diff --git a/src/restic/readerat.go b/src/restic/readerat.go index 6e6492ab5..320d032a4 100644 --- a/src/restic/readerat.go +++ b/src/restic/readerat.go @@ -20,7 +20,7 @@ func ReaderAt(be Backend, h Handle) io.ReaderAt { // 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) + rd, err := be.Load(h, len(p), offset) if err != nil { return 0, err } diff --git a/src/restic/repository/repack.go b/src/restic/repository/repack.go index 8c1edc4a5..f58932ff6 100644 --- a/src/restic/repository/repack.go +++ b/src/restic/repository/repack.go @@ -30,7 +30,7 @@ func Repack(repo restic.Repository, packs restic.IDSet, keepBlobs restic.BlobSet return errors.Wrap(err, "TempFile") } - beRd, err := repo.Backend().Get(h, 0, 0) + beRd, err := repo.Backend().Load(h, 0, 0) if err != nil { return err }