repository: change LoadBlob, LookupBlob and LookupBlobSize to BlobHandles (#21857)

This commit is contained in:
Michael Eischer
2026-06-14 15:30:00 +02:00
committed by GitHub
parent 71f38d266c
commit 7d36449ea8
27 changed files with 85 additions and 85 deletions
+2 -2
View File
@@ -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
}
+3 -3
View File
@@ -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")
}
+1 -1
View File
@@ -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
}
+1 -1
View File
@@ -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 {