diff --git a/src/restic/find.go b/src/restic/find.go index 9e9af63f7..63c8bd813 100644 --- a/src/restic/find.go +++ b/src/restic/find.go @@ -6,8 +6,10 @@ import ( "restic/repository" ) -// findUsedBlobs traverse the tree ID and adds all seen blobs to blobs. -func findUsedBlobs(repo *repository.Repository, treeID backend.ID, blobs pack.BlobSet, seen pack.BlobSet) error { +// FindUsedBlobs traverses the tree ID and adds all seen blobs (trees and data +// blobs) to the set blobs. The tree blobs in the `seen` BlobSet will not be visited +// again. +func FindUsedBlobs(repo *repository.Repository, treeID backend.ID, blobs pack.BlobSet, seen pack.BlobSet) error { blobs.Insert(pack.Handle{ID: treeID, Type: pack.Tree}) tree, err := LoadTree(repo, treeID) @@ -30,7 +32,7 @@ func findUsedBlobs(repo *repository.Repository, treeID backend.ID, blobs pack.Bl seen.Insert(h) - err := findUsedBlobs(repo, subtreeID, blobs, seen) + err := FindUsedBlobs(repo, subtreeID, blobs, seen) if err != nil { return err } @@ -39,8 +41,3 @@ func findUsedBlobs(repo *repository.Repository, treeID backend.ID, blobs pack.Bl return nil } - -// FindUsedBlobs traverses the tree ID and adds all seen blobs (trees and data blobs) to the set blobs. -func FindUsedBlobs(repo *repository.Repository, treeID backend.ID, blobs pack.BlobSet) error { - return findUsedBlobs(repo, treeID, blobs, pack.NewBlobSet()) -} diff --git a/src/restic/repository/index_rebuild.go b/src/restic/repository/index_rebuild.go index e18d08f1f..2fd3e4ea5 100644 --- a/src/restic/repository/index_rebuild.go +++ b/src/restic/repository/index_rebuild.go @@ -11,8 +11,8 @@ import ( const rebuildIndexWorkers = 10 -// LoadBlobsResult is returned in the channel from LoadBlobsFromAllPacks. -type LoadBlobsResult struct { +// ListAllPacksResult is returned in the channel from LoadBlobsFromAllPacks. +type ListAllPacksResult struct { PackID backend.ID Entries []pack.Blob } @@ -22,7 +22,7 @@ func ListAllPacks(repo *Repository, ch chan<- worker.Job, done <-chan struct{}) f := func(job worker.Job, done <-chan struct{}) (interface{}, error) { packID := job.Data.(backend.ID) entries, err := repo.ListPack(packID) - return LoadBlobsResult{ + return ListAllPacksResult{ PackID: packID, Entries: entries, }, err @@ -66,7 +66,7 @@ func RebuildIndex(repo *Repository) error { continue } - res := job.Result.(LoadBlobsResult) + res := job.Result.(ListAllPacksResult) for _, entry := range res.Entries { pb := PackedBlob{