LoadDataBlob -> LoadBlob
This commit is contained in:
parent
fe8c12c798
commit
436332d5f2
8 changed files with 17 additions and 17 deletions
|
@ -173,7 +173,7 @@ func (cmd CmdCat) Execute(args []string) error {
|
||||||
blob := list[0]
|
blob := list[0]
|
||||||
|
|
||||||
buf := make([]byte, blob.Length)
|
buf := make([]byte, blob.Length)
|
||||||
n, err := repo.LoadDataBlob(id, buf)
|
n, err := repo.LoadBlob(restic.DataBlob, id, buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func loadBlob(t *testing.T, repo restic.Repository, id restic.ID, buf []byte) int {
|
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 {
|
if err != nil {
|
||||||
t.Fatalf("LoadBlob(%v) returned error %v", id, err)
|
t.Fatalf("LoadBlob(%v) returned error %v", id, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ var _ = fs.HandleReleaser(&file{})
|
||||||
// for fuse operations.
|
// for fuse operations.
|
||||||
type BlobLoader interface {
|
type BlobLoader interface {
|
||||||
LookupBlobSize(restic.ID, restic.BlobType) (uint, error)
|
LookupBlobSize(restic.ID, restic.BlobType) (uint, error)
|
||||||
LoadDataBlob(restic.ID, []byte) (int, error)
|
LoadBlob(restic.BlobType, restic.ID, []byte) (int, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type file struct {
|
type file struct {
|
||||||
|
@ -109,7 +109,7 @@ func (f *file) getBlobAt(i int) (blob []byte, err error) {
|
||||||
buf = make([]byte, f.sizes[i])
|
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 {
|
if err != nil {
|
||||||
debug.Log("file.getBlobAt", "LoadBlob(%v, %v) failed: %v", f.node.Name, f.node.Content[i], err)
|
debug.Log("file.getBlobAt", "LoadBlob(%v, %v) failed: %v", f.node.Name, f.node.Content[i], err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -34,8 +34,8 @@ func (m *MockRepo) LookupBlobSize(id restic.ID, t restic.BlobType) (uint, error)
|
||||||
return uint(len(buf)), nil
|
return uint(len(buf)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockRepo) LoadDataBlob(id restic.ID, buf []byte) (int, error) {
|
func (m *MockRepo) LoadBlob(t restic.BlobType, id restic.ID, buf []byte) (int, error) {
|
||||||
size, err := m.LookupBlobSize(id, restic.DataBlob)
|
size, err := m.LookupBlobSize(id, t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,7 @@ func (node Node) createFileAt(path string, repo Repository) error {
|
||||||
buf = make([]byte, size)
|
buf = make([]byte, size)
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err := repo.LoadDataBlob(id, buf)
|
n, err := repo.LoadBlob(DataBlob, id, buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,8 @@ type Repository interface {
|
||||||
LoadJSONUnpacked(FileType, ID, interface{}) error
|
LoadJSONUnpacked(FileType, ID, interface{}) error
|
||||||
LoadAndDecrypt(FileType, ID) ([]byte, error)
|
LoadAndDecrypt(FileType, ID) ([]byte, error)
|
||||||
|
|
||||||
LoadTree(id ID) (*Tree, error)
|
LoadTree(ID) (*Tree, error)
|
||||||
LoadDataBlob(id ID, buf []byte) (int, error)
|
LoadBlob(BlobType, ID, []byte) (int, error)
|
||||||
|
|
||||||
SaveBlob(BlobType, []byte, ID) (ID, error)
|
SaveBlob(BlobType, []byte, ID) (ID, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -592,10 +592,10 @@ func (r *Repository) LoadTree(id restic.ID) (*restic.Tree, error) {
|
||||||
return t, nil
|
return t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadDataBlob loads a data blob from the repository to the buffer.
|
// LoadBlob loads a blob of type t from the repository to the buffer.
|
||||||
func (r *Repository) LoadDataBlob(id restic.ID, buf []byte) (int, error) {
|
func (r *Repository) LoadBlob(t restic.BlobType, id restic.ID, buf []byte) (int, error) {
|
||||||
debug.Log("repo.LoadDataBlob", "load blob %v into buf %p", id.Str(), buf)
|
debug.Log("repo.LoadBlob", "load blob %v into buf %p", id.Str(), buf)
|
||||||
size, err := r.idx.LookupSize(id, restic.DataBlob)
|
size, err := r.idx.LookupSize(id, t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
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)
|
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 {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
buf = buf[:n]
|
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
|
return len(buf), err
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ func TestSave(t *testing.T) {
|
||||||
|
|
||||||
// read back
|
// read back
|
||||||
buf := make([]byte, size)
|
buf := make([]byte, size)
|
||||||
n, err := repo.LoadDataBlob(id, buf)
|
n, err := repo.LoadBlob(restic.DataBlob, id, buf)
|
||||||
OK(t, err)
|
OK(t, err)
|
||||||
Equals(t, len(buf), n)
|
Equals(t, len(buf), n)
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ func TestSaveFrom(t *testing.T) {
|
||||||
|
|
||||||
// read back
|
// read back
|
||||||
buf := make([]byte, size)
|
buf := make([]byte, size)
|
||||||
n, err := repo.LoadDataBlob(id, buf)
|
n, err := repo.LoadBlob(restic.DataBlob, id, buf)
|
||||||
OK(t, err)
|
OK(t, err)
|
||||||
Equals(t, len(buf), n)
|
Equals(t, len(buf), n)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue