mirror of
https://github.com/restic/restic.git
synced 2025-12-10 03:11:58 +00:00
Merge pull request #1549 from MJDSys/more_index_lookup_avoids
More optimizations to avoid calling Index.Lookup()
This commit is contained in:
@@ -165,8 +165,8 @@ func runCat(gopts GlobalOptions, args []string) error {
|
||||
|
||||
case "blob":
|
||||
for _, t := range []restic.BlobType{restic.DataBlob, restic.TreeBlob} {
|
||||
list, err := repo.Index().Lookup(id, t)
|
||||
if err != nil {
|
||||
list, found := repo.Index().Lookup(id, t)
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
blob := list[0]
|
||||
|
||||
@@ -135,9 +135,9 @@ func updateBlobs(repo restic.Repository, blobs restic.BlobSet, stats *DiffStat)
|
||||
stats.TreeBlobs++
|
||||
}
|
||||
|
||||
size, err := repo.LookupBlobSize(h.ID, h.Type)
|
||||
if err != nil {
|
||||
Warnf("unable to find blob size for %v: %v\n", h, err)
|
||||
size, found := repo.LookupBlobSize(h.ID, h.Type)
|
||||
if !found {
|
||||
Warnf("unable to find blob size for %v\n", h)
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -59,9 +59,9 @@ func splitPath(path string) []string {
|
||||
func dumpNode(ctx context.Context, repo restic.Repository, node *restic.Node) error {
|
||||
var buf []byte
|
||||
for _, id := range node.Content {
|
||||
size, err := repo.LookupBlobSize(id, restic.DataBlob)
|
||||
if err != nil {
|
||||
return err
|
||||
size, found := repo.LookupBlobSize(id, restic.DataBlob)
|
||||
if !found {
|
||||
return errors.Errorf("id %v not found in repository", id)
|
||||
}
|
||||
|
||||
buf = buf[:cap(buf)]
|
||||
|
||||
Reference in New Issue
Block a user