mirror of https://github.com/perkeep/perkeep.git
camtool list/sync: fix 3 bugs
1) revert to printing to stdout (broke in
08923e1c00
) for actual output
2) do not warn about different identities when "syncing" to stdout
3) check blob was actually described before using its fields
Change-Id: Ibb3aa4c560e1b0036aba080807400e8820163cc9
This commit is contained in:
parent
da7a9b8dcb
commit
73526917a1
|
@ -71,14 +71,14 @@ func (c *listCmd) RunCommand(args []string) error {
|
||||||
return c.syncCmd.RunCommand(args)
|
return c.syncCmd.RunCommand(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
stdout := os.Stdout
|
stdout := cmdmain.Stdout
|
||||||
defer func() { os.Stdout = stdout }()
|
defer func() { cmdmain.Stdout = stdout }()
|
||||||
pr, pw, err := os.Pipe()
|
pr, pw, err := os.Pipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Could not create pipe to read from stdout: %v", err)
|
return fmt.Errorf("Could not create pipe to read from stdout: %v", err)
|
||||||
}
|
}
|
||||||
defer pr.Close()
|
defer pr.Close()
|
||||||
os.Stdout = pw
|
cmdmain.Stdout = pw
|
||||||
|
|
||||||
if err := c.setClient(); err != nil {
|
if err := c.setClient(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -107,7 +107,12 @@ func (c *listCmd) RunCommand(args []string) error {
|
||||||
return fmt.Errorf("Error when describing blobs %v: %v", blobRefs, err)
|
return fmt.Errorf("Error when describing blobs %v: %v", blobRefs, err)
|
||||||
}
|
}
|
||||||
for _, v := range blobRefs {
|
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 <not described>\n", v)
|
||||||
|
continue
|
||||||
|
}
|
||||||
detailed := detail(blob)
|
detailed := detail(blob)
|
||||||
if detailed != "" {
|
if detailed != "" {
|
||||||
detailed = fmt.Sprintf("\t%v", detailed)
|
detailed = fmt.Sprintf("\t%v", detailed)
|
||||||
|
|
|
@ -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)
|
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):
|
// Warn at the top (and hope the user sees it and can abort if it was a mistake):
|
||||||
fmt.Fprintln(cmdmain.Stderr, differentKeyIDs)
|
fmt.Fprintln(cmdmain.Stderr, differentKeyIDs)
|
||||||
// Warn also at the end (in case the user missed the first one)
|
// 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" {
|
if c.dest == "stdout" {
|
||||||
for sb := range srcBlobs {
|
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()
|
checkSourceError()
|
||||||
return
|
return
|
||||||
|
@ -385,7 +385,7 @@ func (c *syncCmd) doPass(src, dest, thirdLeg blobserver.Storage) (stats SyncStat
|
||||||
}
|
}
|
||||||
|
|
||||||
for sb := range syncBlobs {
|
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)
|
blobReader, size, err := src.FetchStreaming(sb.Ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue