Skip to content

Commit

Permalink
fix show all to ignore errnotfound (#678)
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Sutula <hi@asutula.com>
  • Loading branch information
asutula authored Oct 15, 2020
1 parent 10939c6 commit 6da3826
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
15 changes: 6 additions & 9 deletions cmd/pow/cmd/ffs_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package cmd

import (
"context"
"fmt"
"time"

"github.com/caarlos0/spin"
"github.com/ipfs/go-cid"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/reflect/protoreflect"
)

Expand All @@ -35,21 +35,18 @@ var ffsShowCmd = &cobra.Command{
if len(args) == 1 {
c, err := cid.Parse(args[0])
checkErr(err)
s := spin.New("%s Getting info for cid...")
s.Start()
res, err = fcClient.FFS.Show(authCtx(ctx), c)
s.Stop()
checkErr(err)

} else {
s := spin.New("%s Getting info all stored cids...")
s.Start()
var err error
res, err = fcClient.FFS.ShowAll(authCtx(ctx))
s.Stop()
checkErr(err)
}

Success("\n%v", prototext.Format(res))
json, err := protojson.MarshalOptions{Multiline: true, Indent: " "}.Marshal(res)
checkErr(err)

fmt.Println(string(json))
},
}
3 changes: 3 additions & 0 deletions ffs/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,9 @@ func (s *RPC) ShowAll(ctx context.Context, req *ShowAllRequest) (*ShowAllRespons
cidInfos := make([]*CidInfo, len(instanceInfo.Pins))
for j, cid := range instanceInfo.Pins {
cidInfo, err := i.Show(cid)
if err == api.ErrNotFound {
continue
}
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 6da3826

Please sign in to comment.