mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 21:05:10 +00:00
FindUsedBlobs: Check for seen blobs before loading trees
The only effective change in behavior is that that toplevel nodes can also be skipped.
This commit is contained in:
parent
184103647a
commit
9ea1a78bd4
@ -5,7 +5,11 @@ import "context"
|
||||
// FindUsedBlobs traverses the tree ID and adds all seen blobs (trees and data
|
||||
// blobs) to the set blobs. Already seen tree blobs will not be visited again.
|
||||
func FindUsedBlobs(ctx context.Context, repo Repository, treeID ID, blobs BlobSet) error {
|
||||
blobs.Insert(BlobHandle{ID: treeID, Type: TreeBlob})
|
||||
h := BlobHandle{ID: treeID, Type: TreeBlob}
|
||||
if blobs.Has(h) {
|
||||
return nil
|
||||
}
|
||||
blobs.Insert(h)
|
||||
|
||||
tree, err := repo.LoadTree(ctx, treeID)
|
||||
if err != nil {
|
||||
@ -19,13 +23,7 @@ func FindUsedBlobs(ctx context.Context, repo Repository, treeID ID, blobs BlobSe
|
||||
blobs.Insert(BlobHandle{ID: blob, Type: DataBlob})
|
||||
}
|
||||
case "dir":
|
||||
subtreeID := *node.Subtree
|
||||
h := BlobHandle{ID: subtreeID, Type: TreeBlob}
|
||||
if blobs.Has(h) {
|
||||
continue
|
||||
}
|
||||
|
||||
err := FindUsedBlobs(ctx, repo, subtreeID, blobs)
|
||||
err := FindUsedBlobs(ctx, repo, *node.Subtree, blobs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user