mirror of
https://github.com/restic/restic.git
synced 2026-09-27 22:40:29 +00:00
repository: change LoadBlob, LookupBlob and LookupBlobSize to BlobHandles (#21857)
This commit is contained in:
@@ -163,11 +163,11 @@ func TestMultiFindUsedBlobs(t *testing.T) {
|
||||
|
||||
type ForbiddenRepo struct{}
|
||||
|
||||
func (r ForbiddenRepo) LoadBlob(context.Context, restic.BlobType, restic.ID, []byte) ([]byte, error) {
|
||||
func (r ForbiddenRepo) LoadBlob(context.Context, restic.BlobHandle, []byte) ([]byte, error) {
|
||||
return nil, errors.New("should not be called")
|
||||
}
|
||||
|
||||
func (r ForbiddenRepo) LookupBlobSize(_ restic.BlobType, _ restic.ID) (uint, bool) {
|
||||
func (r ForbiddenRepo) LookupBlobSize(_ restic.BlobHandle) (uint, bool) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
|
||||
@@ -202,11 +202,11 @@ func TestLoadAllSnapshots(ctx context.Context, repo restic.ListerLoaderUnpacked,
|
||||
// TestTreeMap returns the trees from the map on LoadTree.
|
||||
type TestTreeMap map[restic.ID][]byte
|
||||
|
||||
func (t TestTreeMap) LoadBlob(_ context.Context, tpe restic.BlobType, id restic.ID, _ []byte) ([]byte, error) {
|
||||
if tpe != restic.TreeBlob {
|
||||
func (t TestTreeMap) LoadBlob(_ context.Context, bh restic.BlobHandle, _ []byte) ([]byte, error) {
|
||||
if bh.Type != restic.TreeBlob {
|
||||
return nil, fmt.Errorf("can only load trees")
|
||||
}
|
||||
tree, ok := t[id]
|
||||
tree, ok := t[bh.ID]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("tree not found")
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ func (t *treeIterator) assertToken(token json.Token) error {
|
||||
}
|
||||
|
||||
func LoadTree(ctx context.Context, loader restic.BlobLoader, content restic.ID) (TreeNodeIterator, error) {
|
||||
rd, err := loader.LoadBlob(ctx, restic.TreeBlob, content, nil)
|
||||
rd, err := loader.LoadBlob(ctx, restic.BlobHandle{Type: restic.TreeBlob, ID: content}, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ func filterTrees(ctx context.Context, repo restic.Loader, trees restic.IDs, load
|
||||
continue
|
||||
}
|
||||
|
||||
treeSize, found := repo.LookupBlobSize(restic.TreeBlob, nextTreeID.ID)
|
||||
treeSize, found := repo.LookupBlobSize(restic.BlobHandle{Type: restic.TreeBlob, ID: nextTreeID.ID})
|
||||
if found && treeSize > 50*1024*1024 {
|
||||
loadCh = hugeTreeLoaderChan
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user