mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
gc: handle errs in toRawCids()
Not that they will ever happen in the current implementation, but it makes the linter happy and covers our back for future.
This commit is contained in:
parent
fc56055892
commit
8d2d9185fb
15
gc/gc.go
15
gc/gc.go
@ -29,13 +29,13 @@ type Result struct {
|
||||
}
|
||||
|
||||
// converts a set of CIDs with different codecs to a set of CIDs with the raw codec.
|
||||
func toRawCids(set *cid.Set) *cid.Set {
|
||||
func toRawCids(set *cid.Set) (*cid.Set, error) {
|
||||
newSet := cid.NewSet()
|
||||
set.ForEach(func(c cid.Cid) error {
|
||||
err := set.ForEach(func(c cid.Cid) error {
|
||||
newSet.Add(cid.NewCidV1(cid.Raw, c.Hash()))
|
||||
return nil
|
||||
})
|
||||
return newSet
|
||||
return newSet, err
|
||||
}
|
||||
|
||||
// GC performs a mark and sweep garbage collection of the blocks in the blockstore
|
||||
@ -72,7 +72,14 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn
|
||||
}
|
||||
|
||||
// The blockstore reports raw blocks. We need to remove the codecs from the CIDs.
|
||||
gcs = toRawCids(gcs)
|
||||
gcs, err = toRawCids(gcs)
|
||||
if err != nil {
|
||||
select {
|
||||
case output <- Result{Error: err}:
|
||||
case <-ctx.Done():
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
keychan, err := bs.AllKeysChan(ctx)
|
||||
if err != nil {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user