check underlying datastore for objects before putting to bufbstore

This commit is contained in:
whyrusleeping 2020-07-02 16:48:14 -07:00
parent 5de7b62dbc
commit 809a3ba07c

View File

@ -108,6 +108,15 @@ func (bs *BufferedBS) GetSize(c cid.Cid) (int, error) {
} }
func (bs *BufferedBS) Put(blk block.Block) error { func (bs *BufferedBS) Put(blk block.Block) error {
has, err := bs.read.Has(blk.Cid())
if err != nil {
return err
}
if has {
return nil
}
return bs.write.Put(blk) return bs.write.Put(blk)
} }