From 436332d5f2d47fada8f5877be79b8bed4685c019 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 3 Sep 2016 20:20:14 +0200 Subject: [PATCH] LoadDataBlob -> LoadBlob --- src/cmds/restic/cmd_cat.go | 2 +- src/restic/archiver/archive_reader_test.go | 2 +- src/restic/fuse/file.go | 4 ++-- src/restic/fuse/file_test.go | 4 ++-- src/restic/node.go | 2 +- src/restic/repository.go | 4 ++-- src/restic/repository/repository.go | 12 ++++++------ src/restic/repository/repository_test.go | 4 ++-- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/cmds/restic/cmd_cat.go b/src/cmds/restic/cmd_cat.go index d5bae8b06..802257066 100644 --- a/src/cmds/restic/cmd_cat.go +++ b/src/cmds/restic/cmd_cat.go @@ -173,7 +173,7 @@ func (cmd CmdCat) Execute(args []string) error { blob := list[0] buf := make([]byte, blob.Length) - n, err := repo.LoadDataBlob(id, buf) + n, err := repo.LoadBlob(restic.DataBlob, id, buf) if err != nil { return err } diff --git a/src/restic/archiver/archive_reader_test.go b/src/restic/archiver/archive_reader_test.go index f9417cb51..86c8a4ca8 100644 --- a/src/restic/archiver/archive_reader_test.go +++ b/src/restic/archiver/archive_reader_test.go @@ -10,7 +10,7 @@ import ( ) func loadBlob(t *testing.T, repo restic.Repository, id restic.ID, buf []byte) int { - n, err := repo.LoadDataBlob(id, buf) + n, err := repo.LoadBlob(restic.DataBlob, id, buf) if err != nil { t.Fatalf("LoadBlob(%v) returned error %v", id, err) } diff --git a/src/restic/fuse/file.go b/src/restic/fuse/file.go index ae1b90124..6590b2635 100644 --- a/src/restic/fuse/file.go +++ b/src/restic/fuse/file.go @@ -27,7 +27,7 @@ var _ = fs.HandleReleaser(&file{}) // for fuse operations. type BlobLoader interface { LookupBlobSize(restic.ID, restic.BlobType) (uint, error) - LoadDataBlob(restic.ID, []byte) (int, error) + LoadBlob(restic.BlobType, restic.ID, []byte) (int, error) } type file struct { @@ -109,7 +109,7 @@ func (f *file) getBlobAt(i int) (blob []byte, err error) { buf = make([]byte, f.sizes[i]) } - n, err := f.repo.LoadDataBlob(f.node.Content[i], buf) + n, err := f.repo.LoadBlob(restic.DataBlob, f.node.Content[i], buf) if err != nil { debug.Log("file.getBlobAt", "LoadBlob(%v, %v) failed: %v", f.node.Name, f.node.Content[i], err) return nil, err diff --git a/src/restic/fuse/file_test.go b/src/restic/fuse/file_test.go index 1013a07b5..090e43200 100644 --- a/src/restic/fuse/file_test.go +++ b/src/restic/fuse/file_test.go @@ -34,8 +34,8 @@ func (m *MockRepo) LookupBlobSize(id restic.ID, t restic.BlobType) (uint, error) return uint(len(buf)), nil } -func (m *MockRepo) LoadDataBlob(id restic.ID, buf []byte) (int, error) { - size, err := m.LookupBlobSize(id, restic.DataBlob) +func (m *MockRepo) LoadBlob(t restic.BlobType, id restic.ID, buf []byte) (int, error) { + size, err := m.LookupBlobSize(id, t) if err != nil { return 0, err } diff --git a/src/restic/node.go b/src/restic/node.go index bc80835bf..1d33aa6ad 100644 --- a/src/restic/node.go +++ b/src/restic/node.go @@ -219,7 +219,7 @@ func (node Node) createFileAt(path string, repo Repository) error { buf = make([]byte, size) } - n, err := repo.LoadDataBlob(id, buf) + n, err := repo.LoadBlob(DataBlob, id, buf) if err != nil { return err } diff --git a/src/restic/repository.go b/src/restic/repository.go index bf8d31453..c84ba4fd9 100644 --- a/src/restic/repository.go +++ b/src/restic/repository.go @@ -34,8 +34,8 @@ type Repository interface { LoadJSONUnpacked(FileType, ID, interface{}) error LoadAndDecrypt(FileType, ID) ([]byte, error) - LoadTree(id ID) (*Tree, error) - LoadDataBlob(id ID, buf []byte) (int, error) + LoadTree(ID) (*Tree, error) + LoadBlob(BlobType, ID, []byte) (int, error) SaveBlob(BlobType, []byte, ID) (ID, error) } diff --git a/src/restic/repository/repository.go b/src/restic/repository/repository.go index 55b9ea1be..9c2e90e31 100644 --- a/src/restic/repository/repository.go +++ b/src/restic/repository/repository.go @@ -592,10 +592,10 @@ func (r *Repository) LoadTree(id restic.ID) (*restic.Tree, error) { return t, nil } -// LoadDataBlob loads a data blob from the repository to the buffer. -func (r *Repository) LoadDataBlob(id restic.ID, buf []byte) (int, error) { - debug.Log("repo.LoadDataBlob", "load blob %v into buf %p", id.Str(), buf) - size, err := r.idx.LookupSize(id, restic.DataBlob) +// LoadBlob loads a blob of type t from the repository to the buffer. +func (r *Repository) LoadBlob(t restic.BlobType, id restic.ID, buf []byte) (int, error) { + debug.Log("repo.LoadBlob", "load blob %v into buf %p", id.Str(), buf) + size, err := r.idx.LookupSize(id, t) if err != nil { return 0, err } @@ -604,13 +604,13 @@ func (r *Repository) LoadDataBlob(id restic.ID, buf []byte) (int, error) { return 0, errors.Errorf("buffer is too small for data blob (%d < %d)", len(buf), size) } - n, err := r.loadBlob(id, restic.DataBlob, buf) + n, err := r.loadBlob(id, t, buf) if err != nil { return 0, err } buf = buf[:n] - debug.Log("repo.LoadDataBlob", "loaded %d bytes into buf %p", len(buf), buf) + debug.Log("repo.LoadBlob", "loaded %d bytes into buf %p", len(buf), buf) return len(buf), err } diff --git a/src/restic/repository/repository_test.go b/src/restic/repository/repository_test.go index 1b93dc8b0..3910f57be 100644 --- a/src/restic/repository/repository_test.go +++ b/src/restic/repository/repository_test.go @@ -91,7 +91,7 @@ func TestSave(t *testing.T) { // read back buf := make([]byte, size) - n, err := repo.LoadDataBlob(id, buf) + n, err := repo.LoadBlob(restic.DataBlob, id, buf) OK(t, err) Equals(t, len(buf), n) @@ -125,7 +125,7 @@ func TestSaveFrom(t *testing.T) { // read back buf := make([]byte, size) - n, err := repo.LoadDataBlob(id, buf) + n, err := repo.LoadBlob(restic.DataBlob, id, buf) OK(t, err) Equals(t, len(buf), n)