mirror of https://github.com/restic/restic.git
Export FindUsedBlobs
This commit is contained in:
parent
2b1b6d8c2a
commit
d7e5f11b78
|
@ -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())
|
||||
}
|
||||
|
|
|
@ -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{
|
||||
|
|
Loading…
Reference in New Issue