mirror of
https://github.com/octoleo/restic.git
synced 2025-01-05 08:02:22 +00:00
cache: Refuse to cache truncated files
This commit is contained in:
parent
d886bc6c48
commit
cebee0b8fa
10
internal/cache/file.go
vendored
10
internal/cache/file.go
vendored
@ -111,13 +111,21 @@ func (c *Cache) Save(h restic.Handle, rd io.Reader) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = io.Copy(f, rd); err != nil {
|
n, err := io.Copy(f, rd)
|
||||||
|
if err != nil {
|
||||||
_ = f.Close()
|
_ = f.Close()
|
||||||
_ = c.Remove(h)
|
_ = c.Remove(h)
|
||||||
return errors.Wrap(err, "Copy")
|
return errors.Wrap(err, "Copy")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if n <= crypto.Extension {
|
||||||
|
_ = f.Close()
|
||||||
|
_ = c.Remove(h)
|
||||||
|
return errors.Errorf("trying to cache truncated file %v", h)
|
||||||
|
}
|
||||||
|
|
||||||
if err = f.Close(); err != nil {
|
if err = f.Close(); err != nil {
|
||||||
|
_ = c.Remove(h)
|
||||||
return errors.Wrap(err, "Close")
|
return errors.Wrap(err, "Close")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user