From 9adae5521d3d148e8c1716e9e69cad227feefbdb Mon Sep 17 00:00:00 2001 From: greatroar <61184462+greatroar@users.noreply.github.com> Date: Fri, 21 Oct 2022 14:32:06 +0200 Subject: [PATCH] cache: Call interface method once --- internal/cache/file.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/cache/file.go b/internal/cache/file.go index 490b2b311..8dafdfc56 100644 --- a/internal/cache/file.go +++ b/internal/cache/file.go @@ -59,13 +59,14 @@ func (c *Cache) load(h restic.Handle, length int, offset int64) (io.ReadCloser, return nil, errors.WithStack(err) } - if fi.Size() <= int64(crypto.CiphertextLength(0)) { + size := fi.Size() + if size <= int64(crypto.CiphertextLength(0)) { _ = f.Close() _ = c.remove(h) return nil, errors.Errorf("cached file %v is truncated, removing", h) } - if fi.Size() < offset+int64(length) { + if size < offset+int64(length) { _ = f.Close() _ = c.remove(h) return nil, errors.Errorf("cached file %v is too small, removing", h)