mirror of
https://github.com/restic/restic.git
synced 2025-08-12 11:47:43 +00:00
Merge pull request #1549 from MJDSys/more_index_lookup_avoids
More optimizations to avoid calling Index.Lookup()
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
package fuse
|
||||
|
||||
import (
|
||||
"github.com/restic/restic/internal/errors"
|
||||
"github.com/restic/restic/internal/restic"
|
||||
|
||||
"github.com/restic/restic/internal/debug"
|
||||
@@ -36,9 +37,10 @@ func newFile(ctx context.Context, root *Root, inode uint64, node *restic.Node) (
|
||||
for i, id := range node.Content {
|
||||
size, ok := root.blobSizeCache.Lookup(id)
|
||||
if !ok {
|
||||
size, err = root.repo.LookupBlobSize(id, restic.DataBlob)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var found bool
|
||||
size, found = root.repo.LookupBlobSize(id, restic.DataBlob)
|
||||
if !found {
|
||||
return nil, errors.Errorf("id %v not found in repository", id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -87,8 +87,8 @@ func TestFuseFile(t *testing.T) {
|
||||
memfile []byte
|
||||
)
|
||||
for _, id := range content {
|
||||
size, err := repo.LookupBlobSize(id, restic.DataBlob)
|
||||
rtest.OK(t, err)
|
||||
size, found := repo.LookupBlobSize(id, restic.DataBlob)
|
||||
rtest.Assert(t, found, "Expected to find blob id %v", id)
|
||||
filesize += uint64(size)
|
||||
|
||||
buf := restic.NewBlobBuffer(int(size))
|
||||
|
Reference in New Issue
Block a user