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-pinner
Commits
9f4a5307
Commit
9f4a5307
authored
7 years ago
by
Jakub Sztandera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Significanly improve GC UX with verifcid
License: MIT Signed-off-by:
Jakub Sztandera
<
kubuxu@protonmail.ch
>
parent
28826e12
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
1 deletion
+25
-1
gc/gc.go
gc/gc.go
+25
-1
No files found.
gc/gc.go
View file @
9f4a5307
...
...
@@ -5,11 +5,13 @@ import (
"context"
"errors"
"fmt"
"strings"
bserv
"github.com/ipfs/go-ipfs/blockservice"
offline
"github.com/ipfs/go-ipfs/exchange/offline"
dag
"github.com/ipfs/go-ipfs/merkledag"
pin
"github.com/ipfs/go-ipfs/pin"
"github.com/ipfs/go-ipfs/thirdparty/verifcid"
dstore
"gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
logging
"gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log"
...
...
@@ -129,12 +131,34 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn
// adds them to the given cid.Set, using the provided dag.GetLinks function
// to walk the tree.
func
Descendants
(
ctx
context
.
Context
,
getLinks
dag
.
GetLinks
,
set
*
cid
.
Set
,
roots
[]
*
cid
.
Cid
)
error
{
verifyGetLinks
:=
func
(
ctx
context
.
Context
,
c
*
cid
.
Cid
)
([]
*
ipld
.
Link
,
error
)
{
err
:=
verifcid
.
ValidateCid
(
c
)
if
err
!=
nil
{
return
nil
,
err
}
return
getLinks
(
ctx
,
c
)
}
verboseCidError
:=
func
(
err
error
)
error
{
if
strings
.
Contains
(
err
.
Error
(),
verifcid
.
ErrBelowMinimumHashLength
.
Error
())
||
strings
.
Contains
(
err
.
Error
(),
verifcid
.
ErrPossiblyInsecureHashFunction
.
Error
())
{
err
=
fmt
.
Errorf
(
"
\"
%s
\"\n
Please run 'ipfs pin verify'"
+
" to list insecure hashes. If you want to read them,"
+
" please downgrade your go-ipfs to 0.4.13
\n
"
,
err
)
log
.
Error
(
err
)
}
return
err
}
for
_
,
c
:=
range
roots
{
set
.
Add
(
c
)
// EnumerateChildren recursively walks the dag and adds the keys to the given set
err
:=
dag
.
EnumerateChildren
(
ctx
,
getLinks
,
c
,
set
.
Visit
)
err
:=
dag
.
EnumerateChildren
(
ctx
,
verifyGetLinks
,
c
,
set
.
Visit
)
if
err
!=
nil
{
err
=
verboseCidError
(
err
)
return
err
}
}
...
...
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