diff --git a/cmd/camtool/list.go b/cmd/camtool/list.go index e464a1a07..b159a1d9c 100644 --- a/cmd/camtool/list.go +++ b/cmd/camtool/list.go @@ -71,14 +71,14 @@ func (c *listCmd) RunCommand(args []string) error { return c.syncCmd.RunCommand(args) } - stdout := os.Stdout - defer func() { os.Stdout = stdout }() + stdout := cmdmain.Stdout + defer func() { cmdmain.Stdout = stdout }() pr, pw, err := os.Pipe() if err != nil { return fmt.Errorf("Could not create pipe to read from stdout: %v", err) } defer pr.Close() - os.Stdout = pw + cmdmain.Stdout = pw if err := c.setClient(); err != nil { return err @@ -107,7 +107,12 @@ func (c *listCmd) RunCommand(args []string) error { return fmt.Errorf("Error when describing blobs %v: %v", blobRefs, err) } for _, v := range blobRefs { - blob := described.Meta[v.String()] + blob, ok := described.Meta[v.String()] + if !ok { + // This can happen if the index is out of sync with the storage we enum from. + fmt.Fprintf(stdout, "%v \n", v) + continue + } detailed := detail(blob) if detailed != "" { detailed = fmt.Sprintf("\t%v", detailed) diff --git a/cmd/camtool/sync.go b/cmd/camtool/sync.go index 78692dfb8..ed84f10cd 100644 --- a/cmd/camtool/sync.go +++ b/cmd/camtool/sync.go @@ -117,7 +117,7 @@ func (c *syncCmd) RunCommand(args []string) error { differentKeyIDs := fmt.Sprintf("WARNING: the source server GPG key ID (%v) and the destination's (%v) differ. All blobs will be synced, but because the indexer at the other side is indexing claims by a different user, you may not see what you expect in that server's web UI, etc.", c.srcKeyID, c.destKeyID) - if c.srcKeyID != c.destKeyID { // both blank is ok. + if c.dest != "stdout" && c.srcKeyID != c.destKeyID { // both blank is ok. // Warn at the top (and hope the user sees it and can abort if it was a mistake): fmt.Fprintln(cmdmain.Stderr, differentKeyIDs) // Warn also at the end (in case the user missed the first one) @@ -325,7 +325,7 @@ func (c *syncCmd) doPass(src, dest, thirdLeg blobserver.Storage) (stats SyncStat if c.dest == "stdout" { for sb := range srcBlobs { - fmt.Fprintf(cmdmain.Stderr, "%s %d\n", sb.Ref, sb.Size) + fmt.Fprintf(cmdmain.Stdout, "%s %d\n", sb.Ref, sb.Size) } checkSourceError() return @@ -385,7 +385,7 @@ func (c *syncCmd) doPass(src, dest, thirdLeg blobserver.Storage) (stats SyncStat } for sb := range syncBlobs { - fmt.Fprintf(cmdmain.Stderr, "Destination needs blob: %s\n", sb) + fmt.Fprintf(cmdmain.Stdout, "Destination needs blob: %s\n", sb) blobReader, size, err := src.FetchStreaming(sb.Ref) if err != nil {