forked from TrueCloudLab/restic
cache: Call interface method once
This commit is contained in:
parent
b513597546
commit
9adae5521d
1 changed files with 3 additions and 2 deletions
5
internal/cache/file.go
vendored
5
internal/cache/file.go
vendored
|
@ -59,13 +59,14 @@ func (c *Cache) load(h restic.Handle, length int, offset int64) (io.ReadCloser,
|
||||||
return nil, errors.WithStack(err)
|
return nil, errors.WithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if fi.Size() <= int64(crypto.CiphertextLength(0)) {
|
size := fi.Size()
|
||||||
|
if size <= int64(crypto.CiphertextLength(0)) {
|
||||||
_ = f.Close()
|
_ = f.Close()
|
||||||
_ = c.remove(h)
|
_ = c.remove(h)
|
||||||
return nil, errors.Errorf("cached file %v is truncated, removing", 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()
|
_ = f.Close()
|
||||||
_ = c.remove(h)
|
_ = c.remove(h)
|
||||||
return nil, errors.Errorf("cached file %v is too small, removing", h)
|
return nil, errors.Errorf("cached file %v is too small, removing", h)
|
||||||
|
|
Loading…
Reference in a new issue