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
74024d0b
Unverified
Commit
74024d0b
authored
Oct 04, 2018
by
Steven Allen
Committed by
GitHub
Oct 04, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16 from ipfs/fix/get-size-not-found
make arccache.GetSize return ErrNotFound when not found
parents
31243bdd
79b1edf4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
arc_cache.go
arc_cache.go
+5
-2
arc_cache_test.go
arc_cache_test.go
+2
-3
No files found.
arc_cache.go
View file @
74024d0b
...
...
@@ -88,8 +88,11 @@ func (b *arccache) Has(k cid.Cid) (bool, error) {
}
func
(
b
*
arccache
)
GetSize
(
k
cid
.
Cid
)
(
int
,
error
)
{
if
_
,
blockSize
,
ok
:=
b
.
hasCached
(
k
);
ok
{
return
blockSize
,
nil
if
has
,
blockSize
,
ok
:=
b
.
hasCached
(
k
);
ok
{
if
has
{
return
blockSize
,
nil
}
return
-
1
,
ErrNotFound
}
blockSize
,
err
:=
b
.
blockstore
.
GetSize
(
k
)
if
err
==
ErrNotFound
{
...
...
arc_cache_test.go
View file @
74024d0b
...
...
@@ -107,7 +107,7 @@ func TestGetFillsCache(t *testing.T) {
if
has
,
err
:=
arc
.
Has
(
exampleBlock
.
Cid
());
has
||
err
!=
nil
{
t
.
Fatal
(
"has was true but there is no such block"
)
}
if
blockSize
,
err
:=
arc
.
GetSize
(
exampleBlock
.
Cid
());
blockSize
>
-
1
||
err
!=
nil
{
if
_
,
err
:=
arc
.
GetSize
(
exampleBlock
.
Cid
());
err
!=
ErrNotFound
{
t
.
Fatal
(
"getsize was true but there is no such block"
)
}
...
...
@@ -203,12 +203,11 @@ func TestGetSizeMissingZeroSizeBlock(t *testing.T) {
arc
.
Get
(
missingBlock
.
Cid
())
trap
(
"has hit datastore"
,
cd
,
t
)
if
blockSize
,
err
:=
arc
.
GetSize
(
missingBlock
.
Cid
());
blockSize
!=
-
1
||
err
!=
nil
{
if
_
,
err
:=
arc
.
GetSize
(
missingBlock
.
Cid
());
err
!=
ErrNotFound
{
t
.
Fatal
(
"getsize returned invalid result"
)
}
}
func
TestDifferentKeyObjectsWork
(
t
*
testing
.
T
)
{
arc
,
bs
,
cd
:=
createStores
(
t
)
...
...
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