diff --git a/src/restic/archive_reader_test.go b/src/restic/archive_reader_test.go index 4397bb90e..49fcbecab 100644 --- a/src/restic/archive_reader_test.go +++ b/src/restic/archive_reader_test.go @@ -13,7 +13,7 @@ import ( ) func loadBlob(t *testing.T, repo *repository.Repository, id backend.ID, buf []byte) []byte { - buf, err := repo.LoadBlob(pack.Data, id, buf) + buf, err := repo.LoadBlob(id, pack.Data, buf) if err != nil { t.Fatalf("LoadBlob(%v) returned error %v", id, err) } diff --git a/src/restic/archiver_duplication_test.go b/src/restic/archiver_duplication_test.go index 1c0193eab..56341a997 100644 --- a/src/restic/archiver_duplication_test.go +++ b/src/restic/archiver_duplication_test.go @@ -101,7 +101,7 @@ func testArchiverDuplication(t *testing.T) { id := randomID() - if repo.Index().Has(id) { + if repo.Index().Has(id, pack.Data) { continue } diff --git a/src/restic/fuse/file.go b/src/restic/fuse/file.go index 8a4095524..ef6766d9e 100644 --- a/src/restic/fuse/file.go +++ b/src/restic/fuse/file.go @@ -27,8 +27,8 @@ var _ = fs.HandleReleaser(&file{}) // BlobLoader is an abstracted repository with a reduced set of methods used // for fuse operations. type BlobLoader interface { - LookupBlobSize(backend.ID) (uint, error) - LoadBlob(pack.BlobType, backend.ID, []byte) ([]byte, error) + LookupBlobSize(backend.ID, pack.BlobType) (uint, error) + LoadBlob(backend.ID, pack.BlobType, []byte) ([]byte, error) } type file struct { @@ -53,7 +53,7 @@ func newFile(repo BlobLoader, node *restic.Node, ownerIsRoot bool) (*file, error var bytes uint64 sizes := make([]uint, len(node.Content)) for i, id := range node.Content { - size, err := repo.LookupBlobSize(id) + size, err := repo.LookupBlobSize(id, pack.Data) if err != nil { return nil, err } @@ -110,7 +110,7 @@ func (f *file) getBlobAt(i int) (blob []byte, err error) { buf = make([]byte, f.sizes[i]) } - blob, err = f.repo.LoadBlob(pack.Data, f.node.Content[i], buf) + blob, err = f.repo.LoadBlob(f.node.Content[i], pack.Data, 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 b334f0bc6..12bcb8598 100644 --- a/src/restic/fuse/file_test.go +++ b/src/restic/fuse/file_test.go @@ -26,7 +26,7 @@ func NewMockRepo(content map[backend.ID][]byte) *MockRepo { return &MockRepo{blobs: content} } -func (m *MockRepo) LookupBlobSize(id backend.ID) (uint, error) { +func (m *MockRepo) LookupBlobSize(id backend.ID, t pack.BlobType) (uint, error) { buf, ok := m.blobs[id] if !ok { return 0, errors.New("blob not found") @@ -35,8 +35,8 @@ func (m *MockRepo) LookupBlobSize(id backend.ID) (uint, error) { return uint(len(buf)), nil } -func (m *MockRepo) LoadBlob(t pack.BlobType, id backend.ID, buf []byte) ([]byte, error) { - size, err := m.LookupBlobSize(id) +func (m *MockRepo) LoadBlob(id backend.ID, t pack.BlobType, buf []byte) ([]byte, error) { + size, err := m.LookupBlobSize(id, t) if err != nil { return nil, err } diff --git a/src/restic/node.go b/src/restic/node.go index 9cce841c1..a2f64dacd 100644 --- a/src/restic/node.go +++ b/src/restic/node.go @@ -226,7 +226,7 @@ func (node Node) createFileAt(path string, repo *repository.Repository) error { buf = make([]byte, size) } - buf, err := repo.LoadBlob(pack.Data, id, buf) + buf, err := repo.LoadBlob(id, pack.Data, buf) if err != nil { return errors.Annotate(err, "Load") } diff --git a/src/restic/repository/repository.go b/src/restic/repository/repository.go index 72a1c1539..1fe2d26d7 100644 --- a/src/restic/repository/repository.go +++ b/src/restic/repository/repository.go @@ -77,7 +77,7 @@ func (r *Repository) LoadAndDecrypt(t backend.Type, id backend.ID) ([]byte, erro // LoadBlob tries to load and decrypt content identified by t and id from a // pack from the backend, the result is stored in plaintextBuf, which must be // large enough to hold the complete blob. -func (r *Repository) LoadBlob(t pack.BlobType, id backend.ID, plaintextBuf []byte) ([]byte, error) { +func (r *Repository) LoadBlob(id backend.ID, t pack.BlobType, plaintextBuf []byte) ([]byte, error) { debug.Log("Repo.LoadBlob", "load %v with id %v", t, id.Str()) // lookup plaintext size of blob @@ -167,7 +167,7 @@ func (r *Repository) LoadJSONUnpacked(t backend.Type, id backend.ID, item interf // LoadJSONPack calls LoadBlob() to load a blob from the backend, decrypt the // data and afterwards call json.Unmarshal on the item. func (r *Repository) LoadJSONPack(t pack.BlobType, id backend.ID, item interface{}) (err error) { - buf, err := r.LoadBlob(t, id, nil) + buf, err := r.LoadBlob(id, t, nil) if err != nil { return err } diff --git a/src/restic/repository/repository_test.go b/src/restic/repository/repository_test.go index 3df824771..db70765a8 100644 --- a/src/restic/repository/repository_test.go +++ b/src/restic/repository/repository_test.go @@ -92,7 +92,7 @@ func TestSave(t *testing.T) { // OK(t, repo.SaveIndex()) // read back - buf, err := repo.LoadBlob(pack.Data, id, make([]byte, size)) + buf, err := repo.LoadBlob(id, pack.Data, make([]byte, size)) OK(t, err) Assert(t, len(buf) == len(data), @@ -124,7 +124,7 @@ func TestSaveFrom(t *testing.T) { OK(t, repo.Flush()) // read back - buf, err := repo.LoadBlob(pack.Data, id, make([]byte, size)) + buf, err := repo.LoadBlob(id, pack.Data, make([]byte, size)) OK(t, err) Assert(t, len(buf) == len(data),