mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 10:58:55 +00:00
cache: Remove files from cache which are too small
This commit is contained in:
parent
abc923f693
commit
5dd0df0162
6
internal/cache/file.go
vendored
6
internal/cache/file.go
vendored
@ -63,6 +63,12 @@ func (c *Cache) Load(h restic.Handle, length int, offset int64) (io.ReadCloser,
|
||||
return nil, errors.Errorf("cached file %v is truncated, removing", h)
|
||||
}
|
||||
|
||||
if fi.Size() < offset+int64(length) {
|
||||
_ = f.Close()
|
||||
_ = c.Remove(h)
|
||||
return nil, errors.Errorf("cached file %v is too small, removing", h)
|
||||
}
|
||||
|
||||
if offset > 0 {
|
||||
if _, err = f.Seek(offset, io.SeekStart); err != nil {
|
||||
_ = f.Close()
|
||||
|
Loading…
Reference in New Issue
Block a user