Added hash checking to dbStore.Get

This commit is contained in:
zsfelfoldi 2015-05-12 18:51:01 +02:00
parent 4e32d8c392
commit 80d398ce6d

View file

@ -324,6 +324,15 @@ func (s *dbStore) Get(key Key) (chunk *Chunk, err error) {
if err != nil {
return
}
hasher := hasherfunc.New()
hasher.Write(data)
if bytes.Compare(hasher.Sum(nil), key) != 0 {
s.db.Delete(getDataKey(index.Idx))
err = notFound
return
}
chunk = &Chunk{
Key: key,
}