LoadDataBlob -> LoadBlob

This commit is contained in:
Alexander Neumann 2016-09-03 20:20:14 +02:00
parent fe8c12c798
commit 436332d5f2
8 changed files with 17 additions and 17 deletions

View file

@ -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
}

View file

@ -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)
}

View file

@ -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

View file

@ -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
}

View file

@ -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
}

View file

@ -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)
}

View file

@ -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
}

View file

@ -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)