check underlying datastore for objects before putting to bufbstore
This commit is contained in:
parent
5de7b62dbc
commit
809a3ba07c
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user