panic if hash returns an error
Add a sanity check that the interface contract is honoured.
This commit is contained in:
parent
51b7e3119b
commit
7c1903e1ee
4 changed files with 16 additions and 4 deletions
|
@ -91,7 +91,10 @@ func (be *MemoryBackend) Save(ctx context.Context, h restic.Handle, rd restic.Re
|
|||
|
||||
beHash := be.Hasher()
|
||||
// must never fail according to interface
|
||||
_, _ = beHash.Write(buf)
|
||||
_, err = beHash.Write(buf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if !bytes.Equal(beHash.Sum(nil), rd.Hash()) {
|
||||
return errors.Errorf("invalid file hash or content, got %s expected %s",
|
||||
base64.RawStdEncoding.EncodeToString(beHash.Sum(nil)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue