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, ...@@ -37,18 +37,15 @@ func newARCCachedBS(ctx context.Context, bs Blockstore, lruSize int) (*arccache,
func (b *arccache) DeleteBlock(k cid.Cid) error { func (b *arccache) DeleteBlock(k cid.Cid) error {
if has, _, ok := b.hasCached(k); ok && !has { if has, _, ok := b.hasCached(k); ok && !has {
return ErrNotFound return nil
} }
b.arc.Remove(k) // Invalidate cache before deleting. b.arc.Remove(k) // Invalidate cache before deleting.
err := b.blockstore.DeleteBlock(k) err := b.blockstore.DeleteBlock(k)
switch err { if err == nil {
case nil, ErrNotFound:
b.cacheHave(k, false) b.cacheHave(k, false)
return err
default:
return err
} }
return err
} }
// if ok == false has is inconclusive // if ok == false has is inconclusive
......
...@@ -139,8 +139,8 @@ func TestGetAndDeleteFalseShortCircuit(t *testing.T) { ...@@ -139,8 +139,8 @@ func TestGetAndDeleteFalseShortCircuit(t *testing.T) {
t.Fatal("get returned invalid result") t.Fatal("get returned invalid result")
} }
if arc.DeleteBlock(exampleBlock.Cid()) != ErrNotFound { if arc.DeleteBlock(exampleBlock.Cid()) != nil {
t.Fatal("expected ErrNotFound error") t.Fatal("expected deletes to be idempotent")
} }
} }
......
...@@ -186,11 +186,7 @@ func (bs *blockstore) GetSize(k cid.Cid) (int, error) { ...@@ -186,11 +186,7 @@ func (bs *blockstore) GetSize(k cid.Cid) (int, error) {
} }
func (bs *blockstore) DeleteBlock(k cid.Cid) error { func (bs *blockstore) DeleteBlock(k cid.Cid) error {
err := bs.datastore.Delete(dshelp.CidToDsKey(k)) return bs.datastore.Delete(dshelp.CidToDsKey(k))
if err == ds.ErrNotFound {
return ErrNotFound
}
return err
} }
// AllKeysChan runs a query for keys from the blockstore. // AllKeysChan runs a query for keys from the blockstore.
......
...@@ -113,7 +113,7 @@ func (b *bloomcache) build(ctx context.Context) error { ...@@ -113,7 +113,7 @@ func (b *bloomcache) build(ctx context.Context) error {
func (b *bloomcache) DeleteBlock(k cid.Cid) error { func (b *bloomcache) DeleteBlock(k cid.Cid) error {
if has, ok := b.hasCached(k); ok && !has { if has, ok := b.hasCached(k); ok && !has {
return ErrNotFound return nil
} }
return b.blockstore.DeleteBlock(k) return b.blockstore.DeleteBlock(k)
......
...@@ -20,6 +20,8 @@ github.com/ipfs/go-cid v0.0.1 h1:GBjWPktLnNyX0JiQCNFpUuUSoMw5KMyqrsejHYlILBE= ...@@ -20,6 +20,8 @@ github.com/ipfs/go-cid v0.0.1 h1:GBjWPktLnNyX0JiQCNFpUuUSoMw5KMyqrsejHYlILBE=
github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
github.com/ipfs/go-datastore v0.0.1 h1:AW/KZCScnBWlSb5JbnEnLKFWXL224LBEh/9KXXOrUms= github.com/ipfs/go-datastore v0.0.1 h1:AW/KZCScnBWlSb5JbnEnLKFWXL224LBEh/9KXXOrUms=
github.com/ipfs/go-datastore v0.0.1/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE= github.com/ipfs/go-datastore v0.0.1/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE=
github.com/ipfs/go-datastore v0.1.0 h1:TOxI04l8CmO4zGtesENhzm4PwkFwJXY3rKiYaaMf9fI=
github.com/ipfs/go-datastore v0.1.0/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE=
github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw=
github.com/ipfs/go-ipfs-ds-help v0.0.1 h1:QBg+Ts2zgeemK/dB0saiF/ykzRGgfoFMT90Rzo0OnVU= github.com/ipfs/go-ipfs-ds-help v0.0.1 h1:QBg+Ts2zgeemK/dB0saiF/ykzRGgfoFMT90Rzo0OnVU=
github.com/ipfs/go-ipfs-ds-help v0.0.1/go.mod h1:gtP9xRaZXqIQRh1HRpp595KbBEdgqWFxefeVKOV8sxo= github.com/ipfs/go-ipfs-ds-help v0.0.1/go.mod h1:gtP9xRaZXqIQRh1HRpp595KbBEdgqWFxefeVKOV8sxo=
......
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