forked from TrueCloudLab/restic
fuse: switch to use bloblru.GetOrCompute
This commit is contained in:
parent
bd03af2feb
commit
7cce667f92
1 changed files with 3 additions and 9 deletions
|
@ -96,20 +96,14 @@ func (f *file) Open(_ context.Context, _ *fuse.OpenRequest, _ *fuse.OpenResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *openFile) getBlobAt(ctx context.Context, i int) (blob []byte, err error) {
|
func (f *openFile) getBlobAt(ctx context.Context, i int) (blob []byte, err error) {
|
||||||
|
blob, err = f.root.blobCache.GetOrCompute(f.node.Content[i], func() ([]byte, error) {
|
||||||
blob, ok := f.root.blobCache.Get(f.node.Content[i])
|
return f.root.repo.LoadBlob(ctx, restic.DataBlob, f.node.Content[i], nil)
|
||||||
if ok {
|
})
|
||||||
return blob, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
blob, err = f.root.repo.LoadBlob(ctx, restic.DataBlob, f.node.Content[i], nil)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
debug.Log("LoadBlob(%v, %v) failed: %v", f.node.Name, f.node.Content[i], err)
|
debug.Log("LoadBlob(%v, %v) failed: %v", f.node.Name, f.node.Content[i], err)
|
||||||
return nil, unwrapCtxCanceled(err)
|
return nil, unwrapCtxCanceled(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
f.root.blobCache.Add(f.node.Content[i], blob)
|
|
||||||
|
|
||||||
return blob, nil
|
return blob, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue