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
Commits
9796a036
Commit
9796a036
authored
8 years ago
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update HashOnRead validation to properly support cids
License: MIT Signed-off-by:
Jeromy
<
why@ipfs.io
>
parent
8ce99632
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
blocks/blockstore/blockstore.go
blocks/blockstore/blockstore.go
+8
-4
test/sharness/t0084-repo-read-rehash.sh
test/sharness/t0084-repo-read-rehash.sh
+5
-0
No files found.
blocks/blockstore/blockstore.go
View file @
9796a036
...
...
@@ -100,12 +100,16 @@ func (bs *blockstore) Get(k *cid.Cid) (blocks.Block, error) {
}
if
bs
.
rehash
{
rb
:=
blocks
.
NewBlock
(
bdata
)
if
!
rb
.
Cid
()
.
Equals
(
k
)
{
rbcid
,
err
:=
k
.
Prefix
()
.
Sum
(
bdata
)
if
err
!=
nil
{
return
nil
,
err
}
if
!
rbcid
.
Equals
(
k
)
{
return
nil
,
ErrHashMismatch
}
else
{
return
rb
,
nil
}
return
blocks
.
NewBlockWithCid
(
bdata
,
rbcid
)
}
else
{
return
blocks
.
NewBlockWithCid
(
bdata
,
k
)
}
...
...
This diff is collapsed.
Click to expand it.
test/sharness/t0084-repo-read-rehash.sh
View file @
9796a036
...
...
@@ -43,6 +43,11 @@ test_check_bad_blocks() {
test_check_bad_blocks
test_expect_success
"can add and cat a raw-leaf file"
'
HASH=$(echo "stuff" | ipfs add -q --raw-leaves) &&
ipfs cat $HASH > /dev/null
'
test_launch_ipfs_daemon
test_check_bad_blocks
test_kill_ipfs_daemon
...
...
This diff is collapsed.
Click to expand it.
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