repository: unexport listPacksFromIndex

`ListPacksFromIndex` only has repository-internal callers left (besides
test code).
This commit is contained in:
Michael Eischer
2026-06-04 21:59:12 +02:00
parent 781c6a12ae
commit c5acfe9469
7 changed files with 17 additions and 20 deletions
+1 -1
View File
@@ -306,7 +306,7 @@ func (c *Checker) ReadPacks(ctx context.Context, filter func(packs map[restic.ID
}
// push packs to ch
for pbs := range c.repo.ListPacksFromIndex(ctx, packSet) {
for pbs := range c.repo.listPacksFromIndex(ctx, packSet) {
size := packs[pbs.PackID]
debug.Log("listed %v", pbs.PackID)
select {
+4 -5
View File
@@ -116,15 +116,14 @@ func ExaminePack(ctx context.Context, repo *Repository, id restic.ID, opts Exami
blobsLoaded := false
// examine all data the indexes have for the pack file
for b := range repo.ListPacksFromIndex(ctx, restic.NewIDSet(id)) {
blobs := b.Blobs
if len(blobs) == 0 {
for b := range repo.listPacksFromIndex(ctx, restic.NewIDSet(id)) {
if len(b.Blobs) == 0 {
continue
}
checkPackSize(blobs, len(buf), printer)
checkPackSize(b.Blobs, len(buf), printer)
err = loadBlobs(ctx, opts, repo, id, blobs, printer)
err = loadBlobs(ctx, opts, repo, id, b.Blobs, printer)
if err != nil {
printer.E("error: %v", err)
} else {
+1 -1
View File
@@ -83,7 +83,7 @@ func repack(
downloadQueue := make(chan restic.PackBlobs)
wg.Go(func() error {
defer close(downloadQueue)
for pbs := range repo.ListPacksFromIndex(wgCtx, packs) {
for pbs := range repo.listPacksFromIndex(wgCtx, packs) {
var packBlobs restic.Blobs
keepMutex.Lock()
// filter out unnecessary blobs
+1 -1
View File
@@ -23,7 +23,7 @@ func RepairPacks(ctx context.Context, repo *Repository, ids restic.IDSet, printe
err = repo.WithBlobUploader(ctx, func(ctx context.Context, uploader restic.BlobSaverWithAsync) error {
// examine all data the indexes have for the pack file
for b := range repo.ListPacksFromIndex(ctx, ids) {
for b := range repo.listPacksFromIndex(ctx, ids) {
indexBlobs := b.Blobs
err := reuploadBlobsFromPack(ctx, repo, b.PackID, indexBlobs, printer, uploader)
if err != nil {
+8 -10
View File
@@ -66,13 +66,11 @@ func testRepairBrokenPack(t *testing.T, version uint) {
// find blob that starts at offset 0
var damagedBlob restic.BlobHandle
for blobs := range repo.ListPacksFromIndex(context.TODO(), restic.NewIDSet(damagedID)) {
for _, blob := range blobs.Blobs {
if blob.Offset == 0 {
damagedBlob = blob.BlobHandle
}
_ = repo.ListBlobs(context.TODO(), func(pb restic.PackedBlob) {
if pb.PackID == damagedID && pb.Offset == 0 {
damagedBlob = pb.BlobHandle
}
}
})
return restic.NewIDSet(damagedID), restic.NewBlobSet(damagedBlob)
},
@@ -89,11 +87,11 @@ func testRepairBrokenPack(t *testing.T, version uint) {
// all blobs in the file are broken
damagedBlobs := restic.NewBlobSet()
for blobs := range repo.ListPacksFromIndex(context.TODO(), restic.NewIDSet(damagedID)) {
for _, blob := range blobs.Blobs {
damagedBlobs.Insert(blob.BlobHandle)
_ = repo.ListBlobs(context.TODO(), func(pb restic.PackedBlob) {
if pb.PackID == damagedID {
damagedBlobs.Insert(pb.BlobHandle)
}
}
})
return restic.NewIDSet(damagedID), damagedBlobs
},
}, {
+2 -1
View File
@@ -691,7 +691,8 @@ func (r *Repository) ListBlobs(ctx context.Context, fn func(restic.PackedBlob))
return nil
}
func (r *Repository) ListPacksFromIndex(ctx context.Context, packs restic.IDSet) <-chan restic.PackBlobs {
// listPacksFromIndex returns index entries for the given packs, grouped by pack file.
func (r *Repository) listPacksFromIndex(ctx context.Context, packs restic.IDSet) <-chan restic.PackBlobs {
return r.idx.ListPacks(ctx, packs)
}
-1
View File
@@ -31,7 +31,6 @@ type Repository interface {
// ListBlobs runs fn on all blobs known to the index. When the context is cancelled,
// the index iteration returns immediately with ctx.Err(). This blocks any modification of the index.
ListBlobs(ctx context.Context, fn func(PackedBlob)) error
ListPacksFromIndex(ctx context.Context, packs IDSet) <-chan PackBlobs
// ListPackHandles returns the blob handles stored in the pack file header.
ListPackHandles(ctx context.Context, id ID, packSize int64) ([]BlobHandle, error)