Skip to content

Commit

Permalink
"block rm": just return "error" in ProcRmOutput
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
  • Loading branch information
kevina committed Sep 15, 2016
1 parent 5901e57 commit 6b2b976
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions blocks/blockstore/util/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,12 @@ func checkIfPinned(pins pin.Pinner, cids []*cid.Cid, out chan<- interface{}) ([]
return stillOkay, nil
}

type RmError struct {
Fatal bool
Msg string
}

func (err RmError) Error() string { return err.Msg }

func ProcRmOutput(in <-chan interface{}, sout io.Writer, serr io.Writer) *RmError {
func ProcRmOutput(in <-chan interface{}, sout io.Writer, serr io.Writer) error {
someFailed := false
for res := range in {
r := res.(*RemovedBlock)
if r.Hash == "" && r.Error != "" {
return &RmError{
Fatal: true,
Msg: fmt.Sprintf("aborted: %s", r.Error),
}
return fmt.Errorf("aborted: %s", r.Error)
} else if r.Error != "" {
someFailed = true
fmt.Fprintf(serr, "cannot remove %s: %s\n", r.Hash, r.Error)
Expand All @@ -92,9 +82,7 @@ func ProcRmOutput(in <-chan interface{}, sout io.Writer, serr io.Writer) *RmErro
}
}
if someFailed {
return &RmError{
Msg: fmt.Sprintf("some blocks not removed"),
}
return fmt.Errorf("some blocks not removed")
}
return nil
}

0 comments on commit 6b2b976

Please sign in to comment.