From 50b724ca23a7cf6d4a00f03143603d48e5a6603a Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 1 Aug 2016 20:44:02 +0200 Subject: [PATCH] Fix stylistic issues with FindUsedBlobs --- src/restic/find.go | 10 ++++------ src/restic/find_test.go | 13 +++++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/restic/find.go b/src/restic/find.go index 974ebf673..dd2ab8ff4 100644 --- a/src/restic/find.go +++ b/src/restic/find.go @@ -5,7 +5,7 @@ import ( "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 { blobs.Insert(treeID) @@ -38,9 +38,7 @@ func findUsedBlobs(repo *repository.Repository, treeID backend.ID, blobs backend return nil } -// FindUsedBlobs traverses the tree ID and returns a set of all blobs -// encountered. -func FindUsedBlobs(repo *repository.Repository, treeID backend.ID) (blobs backend.IDSet, err error) { - blobs = backend.NewIDSet() - return blobs, findUsedBlobs(repo, treeID, blobs, backend.NewIDSet()) +// 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 backend.IDSet) error { + return findUsedBlobs(repo, treeID, blobs, backend.NewIDSet()) } diff --git a/src/restic/find_test.go b/src/restic/find_test.go index 759664f29..5f1c2e0f3 100644 --- a/src/restic/find_test.go +++ b/src/restic/find_test.go @@ -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/") const ( - testSnapshots = 3 - testDepth = 2 + findTestSnapshots = 3 + findTestDepth = 2 ) -var testTime = time.Unix(1469960361, 23) +var findTestTime = time.Unix(1469960361, 23) func TestFindUsedBlobs(t *testing.T) { repo, cleanup := repository.TestRepository(t) defer cleanup() var snapshots []*Snapshot - for i := 0; i < testSnapshots; i++ { - sn := TestCreateSnapshot(t, repo, testTime.Add(time.Duration(i)*time.Second), testDepth) + for i := 0; i < findTestSnapshots; i++ { + 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()) snapshots = append(snapshots, sn) } for i, sn := range snapshots { - usedBlobs, err := FindUsedBlobs(repo, *sn.Tree) + usedBlobs := backend.NewIDSet() + err := FindUsedBlobs(repo, *sn.Tree, usedBlobs) if err != nil { t.Errorf("FindUsedBlobs returned error: %v", err) continue