mirror of
https://github.com/octoleo/restic.git
synced 2024-11-02 11:46:36 +00:00
Fix stylistic issues with FindUsedBlobs
This commit is contained in:
parent
6227821b4e
commit
50b724ca23
@ -5,7 +5,7 @@ import (
|
|||||||
"restic/repository"
|
"restic/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FindUsedBlobs traverse the tree ID and adds all seen blobs to blobs.
|
// findUsedBlobs traverse the tree ID and adds all seen blobs to blobs.
|
||||||
func findUsedBlobs(repo *repository.Repository, treeID backend.ID, blobs backend.IDSet, seen backend.IDSet) error {
|
func findUsedBlobs(repo *repository.Repository, treeID backend.ID, blobs backend.IDSet, seen backend.IDSet) error {
|
||||||
blobs.Insert(treeID)
|
blobs.Insert(treeID)
|
||||||
|
|
||||||
@ -38,9 +38,7 @@ func findUsedBlobs(repo *repository.Repository, treeID backend.ID, blobs backend
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindUsedBlobs traverses the tree ID and returns a set of all blobs
|
// FindUsedBlobs traverses the tree ID and adds all seen blobs (trees and data blobs) to the set blobs.
|
||||||
// encountered.
|
func FindUsedBlobs(repo *repository.Repository, treeID backend.ID, blobs backend.IDSet) error {
|
||||||
func FindUsedBlobs(repo *repository.Repository, treeID backend.ID) (blobs backend.IDSet, err error) {
|
return findUsedBlobs(repo, treeID, blobs, backend.NewIDSet())
|
||||||
blobs = backend.NewIDSet()
|
|
||||||
return blobs, findUsedBlobs(repo, treeID, blobs, backend.NewIDSet())
|
|
||||||
}
|
}
|
||||||
|
@ -65,25 +65,26 @@ func saveIDSet(t testing.TB, filename string, s backend.IDSet) {
|
|||||||
var updateGoldenFiles = flag.Bool("update", false, "update golden files in testdata/")
|
var updateGoldenFiles = flag.Bool("update", false, "update golden files in testdata/")
|
||||||
|
|
||||||
const (
|
const (
|
||||||
testSnapshots = 3
|
findTestSnapshots = 3
|
||||||
testDepth = 2
|
findTestDepth = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
var testTime = time.Unix(1469960361, 23)
|
var findTestTime = time.Unix(1469960361, 23)
|
||||||
|
|
||||||
func TestFindUsedBlobs(t *testing.T) {
|
func TestFindUsedBlobs(t *testing.T) {
|
||||||
repo, cleanup := repository.TestRepository(t)
|
repo, cleanup := repository.TestRepository(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
var snapshots []*Snapshot
|
var snapshots []*Snapshot
|
||||||
for i := 0; i < testSnapshots; i++ {
|
for i := 0; i < findTestSnapshots; i++ {
|
||||||
sn := TestCreateSnapshot(t, repo, testTime.Add(time.Duration(i)*time.Second), testDepth)
|
sn := TestCreateSnapshot(t, repo, findTestTime.Add(time.Duration(i)*time.Second), findTestDepth)
|
||||||
t.Logf("snapshot %v saved, tree %v", sn.ID().Str(), sn.Tree.Str())
|
t.Logf("snapshot %v saved, tree %v", sn.ID().Str(), sn.Tree.Str())
|
||||||
snapshots = append(snapshots, sn)
|
snapshots = append(snapshots, sn)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, sn := range snapshots {
|
for i, sn := range snapshots {
|
||||||
usedBlobs, err := FindUsedBlobs(repo, *sn.Tree)
|
usedBlobs := backend.NewIDSet()
|
||||||
|
err := FindUsedBlobs(repo, *sn.Tree, usedBlobs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("FindUsedBlobs returned error: %v", err)
|
t.Errorf("FindUsedBlobs returned error: %v", err)
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user