Skip to content

Commit

Permalink
gc: continue to use cmds.ChannelMarshaler
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 Mar 19, 2017
1 parent c83bbaf commit f66ca2f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions commands/channelmarshaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ func (cr *ChannelMarshaler) Read(p []byte) (int, error) {
if err != nil {
return 0, err
}
if r == nil {
return 0, nil
}
cr.reader = r
}

Expand Down
18 changes: 9 additions & 9 deletions core/commands/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,29 +110,29 @@ order to reclaim hard disk space.
return nil, err
}

for v := range outChan {
marshal := func(v interface{}) (io.Reader, error) {
obj, ok := v.(*GcResult)
if !ok {
return nil, u.ErrCast()
}

if obj.Error != "" {
fmt.Fprintf(res.Stderr(), "Error: %s\n", obj.Error)
continue
return nil, nil
}

if quiet {
fmt.Fprintf(res.Stdout(), "%s\n", obj.Key.String())
return bytes.NewBufferString(obj.Key.String() + "\n"), nil
} else {
fmt.Fprintf(res.Stdout(), "removed %s\n", obj.Key.String())
return bytes.NewBufferString(fmt.Sprintf("removed %s\n", obj.Key)), nil
}
}

if res.Error() != nil {
return nil, res.Error()
}

return nil, nil
return &cmds.ChannelMarshaler{
Channel: outChan,
Marshaler: marshal,
Res: res,
}, nil
},
},
}
Expand Down

0 comments on commit f66ca2f

Please sign in to comment.