Unverified Commit f0ca3c6c authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #24 from ipfs/dep/update-blockstore

dep: update go-datastore
parents 9ed7988b 9666db5d
......@@ -37,18 +37,15 @@ func newARCCachedBS(ctx context.Context, bs Blockstore, lruSize int) (*arccache,
func (b *arccache) DeleteBlock(k cid.Cid) error {
if has, _, ok := b.hasCached(k); ok && !has {
return ErrNotFound
return nil
}
b.arc.Remove(k) // Invalidate cache before deleting.
err := b.blockstore.DeleteBlock(k)
switch err {
case nil, ErrNotFound:
if err == nil {
b.cacheHave(k, false)
return err
default:
return err
}
return err
}
// if ok == false has is inconclusive
......
......@@ -139,8 +139,8 @@ func TestGetAndDeleteFalseShortCircuit(t *testing.T) {
t.Fatal("get returned invalid result")
}
if arc.DeleteBlock(exampleBlock.Cid()) != ErrNotFound {
t.Fatal("expected ErrNotFound error")
if arc.DeleteBlock(exampleBlock.Cid()) != nil {
t.Fatal("expected deletes to be idempotent")
}
}
......
......@@ -186,11 +186,7 @@ func (bs *blockstore) GetSize(k cid.Cid) (int, error) {
}
func (bs *blockstore) DeleteBlock(k cid.Cid) error {
err := bs.datastore.Delete(dshelp.CidToDsKey(k))
if err == ds.ErrNotFound {
return ErrNotFound
}
return err
return bs.datastore.Delete(dshelp.CidToDsKey(k))
}
// AllKeysChan runs a query for keys from the blockstore.
......
......@@ -113,7 +113,7 @@ func (b *bloomcache) build(ctx context.Context) error {
func (b *bloomcache) DeleteBlock(k cid.Cid) error {
if has, ok := b.hasCached(k); ok && !has {
return ErrNotFound
return nil
}
return b.blockstore.DeleteBlock(k)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment