Merge pull request #1549 from MJDSys/more_index_lookup_avoids

More optimizations to avoid calling Index.Lookup()
This commit is contained in:
Alexander Neumann
2018-01-24 20:53:30 +01:00
17 changed files with 246 additions and 81 deletions

View File

@@ -43,9 +43,9 @@ func checkSavedFile(t *testing.T, repo restic.Repository, treeID restic.ID, name
// check blobs
for i, id := range node.Content {
size, err := repo.LookupBlobSize(id, restic.DataBlob)
if err != nil {
t.Fatal(err)
size, found := repo.LookupBlobSize(id, restic.DataBlob)
if !found {
t.Fatal("Failed to find blob", id.Str())
}
buf := restic.NewBlobBuffer(int(size))
@@ -55,7 +55,7 @@ func checkSavedFile(t *testing.T, repo restic.Repository, treeID restic.ID, name
}
buf2 := make([]byte, int(size))
_, err = io.ReadFull(rd, buf2)
_, err := io.ReadFull(rd, buf2)
if err != nil {
t.Fatal(err)
}

View File

@@ -86,8 +86,7 @@ func (arch *Archiver) isKnownBlob(id restic.ID, t restic.BlobType) bool {
arch.knownBlobs.Insert(id)
_, err := arch.repo.Index().Lookup(id, t)
if err == nil {
if arch.repo.Index().Has(id, t) {
return true
}