Commit 0d5887bd authored by Steven Allen's avatar Steven Allen

correctly convert the datastore not found errors

parent a17a33ce
......@@ -6,7 +6,6 @@ import (
lru "github.com/hashicorp/golang-lru"
blocks "github.com/ipfs/go-block-format"
cid "github.com/ipfs/go-cid"
ds "github.com/ipfs/go-datastore"
metrics "github.com/ipfs/go-metrics-interface"
)
......@@ -41,7 +40,7 @@ func (b *arccache) DeleteBlock(k *cid.Cid) error {
b.arc.Remove(k) // Invalidate cache before deleting.
err := b.blockstore.DeleteBlock(k)
switch err {
case nil, ds.ErrNotFound, ErrNotFound:
case nil, ErrNotFound:
b.addCache(k, -1)
return err
default:
......@@ -74,7 +73,7 @@ func (b *arccache) hasCached(k *cid.Cid) (has bool, size int, ok bool) {
func (b *arccache) Has(k *cid.Cid) (bool, error) {
blockSize, err := b.GetSize(k)
if err == ds.ErrNotFound {
if err == ErrNotFound {
return false, nil
}
return blockSize > -1, err
......@@ -85,7 +84,7 @@ func (b *arccache) GetSize(k *cid.Cid) (int, error) {
return blockSize, nil
}
blockSize, err := b.blockstore.GetSize(k)
if err == ds.ErrNotFound {
if err == ErrNotFound {
b.addCache(k, -1)
} else if err == nil {
b.addCache(k, blockSize)
......
......@@ -188,6 +188,9 @@ func (bs *blockstore) Has(k *cid.Cid) (bool, error) {
func (bs *blockstore) GetSize(k *cid.Cid) (int, error) {
maybeData, err := bs.datastore.Get(dshelp.CidToDsKey(k))
if err == ds.ErrNotFound {
return -1, ErrNotFound
}
if err != nil {
return -1, err
}
......
......@@ -65,7 +65,7 @@ func TestPutManyAddsToBloom(t *testing.T) {
t.Fatal(err)
}
blockSize, err = cachedbs.GetSize(block2.Cid())
if err != nil && err != ds.ErrNotFound {
if err != nil && err != ErrNotFound {
t.Fatal(err)
}
if blockSize > -1 || has {
......
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