only store the blobs in the underlying storage if LFUDA accepted them

This commit is contained in:
Niko Storni 2020-11-25 19:24:32 +01:00 committed by Alex Grintsvayg
parent ff9b61b034
commit 9fc96ac01b
No known key found for this signature in database
GPG key ID: AEB3F089F86A22B5

View file

@ -66,11 +66,14 @@ func (l *LFUDAStore) Get(hash string) (stream.Blob, error) {
// Put stores the blob. Following LFUDA rules it's not guaranteed that a SET will store the value!!!
func (l *LFUDAStore) Put(hash string, blob stream.Blob) error {
l.lfuda.Set(hash, fakeTrue)
has, _ := l.Has(hash)
if has {
err := l.store.Put(hash, blob)
if err != nil {
return err
}
l.lfuda.Set(hash, fakeTrue)
}
return nil
}