@cryptotaxi247 / kubo / commits / ac297a829

chore: block/blockstoreutil remove unused ProcRmOutput function

Jorropo committed Apr 1, 2022 at 15:59 UTC ac297a829e5e4bbc42b2640cf285c5413da70443
1 file changed -28
blocks/blockstoreutil/remove.go
-28
@@ -5,7 +5,6 @@ import (
5 "context"
6 "errors"
7 "fmt"
8 - "io"
8
9 cid "github.com/ipfs/go-cid"
10 bs "github.com/ipfs/go-ipfs-blockstore"
@@ -95,30 +94,3 @@ func FilterPinned(ctx context.Context, pins pin.Pinner, out chan<- interface{},
94 }
95 return stillOkay
96 }
98 -
99 -// ProcRmOutput takes a function which returns a result from RmBlocks or EOF if there is no input.
100 -// It then writes to stdout/stderr according to the RemovedBlock object returned from the function.
101 -func ProcRmOutput(next func() (interface{}, error), sout io.Writer, serr io.Writer) error {
102 - someFailed := false
103 - for {
104 - res, err := next()
105 - if err == io.EOF {
106 - break
107 - } else if err != nil {
108 - return err
109 - }
110 - r := res.(*RemovedBlock)
111 - if r.Hash == "" && r.Error != nil {
112 - return fmt.Errorf("aborted: %w", r.Error)
113 - } else if r.Error != nil {
114 - someFailed = true
115 - fmt.Fprintf(serr, "cannot remove %s: %v\n", r.Hash, r.Error)
116 - } else {
117 - fmt.Fprintf(sout, "removed %s\n", r.Hash)
118 - }
119 - }
120 - if someFailed {
121 - return fmt.Errorf("some blocks not removed")
122 - }
123 - return nil
124 -}