Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3-blockstore
Commits
0d5887bd
Commit
0d5887bd
authored
Aug 06, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correctly convert the datastore not found errors
parent
a17a33ce
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
5 deletions
+7
-5
arc_cache.go
arc_cache.go
+3
-4
blockstore.go
blockstore.go
+3
-0
bloom_cache_test.go
bloom_cache_test.go
+1
-1
No files found.
arc_cache.go
View file @
0d5887bd
...
...
@@ -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
)
...
...
blockstore.go
View file @
0d5887bd
...
...
@@ -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
}
...
...
bloom_cache_test.go
View file @
0d5887bd
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment