@cryptotaxi247 / kubo / commits / 6b2b976c5

"block rm": just return "error" in ProcRmOutput

License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>

Kevin Atkinson committed Sep 15, 2016 at 04:11 UTC 6b2b976c57c5b71066e37d7e74255282e18cb541
1 file changed +3 -15
blocks/blockstore/util/remove.go
+3 -15
@@ -68,22 +68,12 @@ func checkIfPinned(pins pin.Pinner, cids []*cid.Cid, out chan<- interface{}) ([]
68 return stillOkay, nil
69 }
70
71 -type RmError struct {
72 - Fatal bool
73 - Msg string
74 -}
75 -
76 -func (err RmError) Error() string { return err.Msg }
77 -
78 -func ProcRmOutput(in <-chan interface{}, sout io.Writer, serr io.Writer) *RmError {
71 +func ProcRmOutput(in <-chan interface{}, sout io.Writer, serr io.Writer) error {
72 someFailed := false
73 for res := range in {
74 r := res.(*RemovedBlock)
75 if r.Hash == "" && r.Error != "" {
83 - return &RmError{
84 - Fatal: true,
85 - Msg: fmt.Sprintf("aborted: %s", r.Error),
86 - }
76 + return fmt.Errorf("aborted: %s", r.Error)
77 } else if r.Error != "" {
78 someFailed = true
79 fmt.Fprintf(serr, "cannot remove %s: %s\n", r.Hash, r.Error)
@@ -92,9 +82,7 @@ func ProcRmOutput(in <-chan interface{}, sout io.Writer, serr io.Writer) *RmErro
82 }
83 }
84 if someFailed {
95 - return &RmError{
96 - Msg: fmt.Sprintf("some blocks not removed"),
97 - }
85 + return fmt.Errorf("some blocks not removed")
86 }
87 return nil
88 }