Commit bb55b0fb authored by Anton Evangelatov's avatar Anton Evangelatov Committed by Viktor Trón

swarm/storage: add comparison towards leveldb.ErrNotFound (#19243)

* swarm/storage: add comparison towards leveldb.ErrNotFound

* swarm/storage: wrap leveldb ErrNotFound
parent 2cfe0bed
...@@ -1005,7 +1005,10 @@ func (s *LDBStore) get(addr Address) (chunk Chunk, err error) { ...@@ -1005,7 +1005,10 @@ func (s *LDBStore) get(addr Address) (chunk Chunk, err error) {
if err != nil { if err != nil {
log.Trace("ldbstore.get chunk found but could not be accessed", "key", addr, "err", err) log.Trace("ldbstore.get chunk found but could not be accessed", "key", addr, "err", err)
s.deleteNow(index, getIndexKey(addr), s.po(addr)) s.deleteNow(index, getIndexKey(addr), s.po(addr))
return if err == leveldb.ErrNotFound {
return nil, ErrChunkNotFound
}
return nil, err
} }
} }
......
...@@ -29,6 +29,7 @@ import ( ...@@ -29,6 +29,7 @@ import (
"github.com/ethereum/go-ethereum/swarm/spancontext" "github.com/ethereum/go-ethereum/swarm/spancontext"
"github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go"
olog "github.com/opentracing/opentracing-go/log" olog "github.com/opentracing/opentracing-go/log"
"github.com/syndtr/goleveldb/leveldb"
lru "github.com/hashicorp/golang-lru" lru "github.com/hashicorp/golang-lru"
) )
...@@ -167,7 +168,8 @@ func (n *NetStore) get(ctx context.Context, ref Address) (Chunk, func(context.Co ...@@ -167,7 +168,8 @@ func (n *NetStore) get(ctx context.Context, ref Address) (Chunk, func(context.Co
chunk, err := n.store.Get(ctx, ref) chunk, err := n.store.Get(ctx, ref)
if err != nil { if err != nil {
if err != ErrChunkNotFound { // TODO: Fix comparison - we should be comparing against leveldb.ErrNotFound, this error should be wrapped.
if err != ErrChunkNotFound && err != leveldb.ErrNotFound {
log.Debug("Received error from LocalStore other than ErrNotFound", "err", err) log.Debug("Received error from LocalStore other than ErrNotFound", "err", err)
} }
// The chunk is not available in the LocalStore, let's get the fetcher for it, or create a new one // The chunk is not available in the LocalStore, let's get the fetcher for it, or create a new one
......
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