Skip to content

Commit

Permalink
From riyazdf's review
Browse files Browse the repository at this point in the history
Prior to this patch, if we provide a value to the output flag, we
write both to the file as well as stdout which is not consistent
with the flag description and also not the intended.

Signed-off-by: Hu Keping <[email protected]>
  • Loading branch information
HuKeping committed May 10, 2016
1 parent 0f5d22f commit 31a5ebc
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions cmd/notary/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func getPayload(t *tufCommander) ([]byte, error) {

// Reads from the given file
if t.input != "" {
// Please be noticed that ReadFile will cut off the size if it was over 1e9.
// Please note that ReadFile will cut off the size if it was over 1e9.
// Thus, if the size of the file exceeds 1GB, the over part will not be
// loaded into the buffer.
payload, err := ioutil.ReadFile(t.input)
Expand All @@ -33,17 +33,15 @@ func getPayload(t *tufCommander) ([]byte, error) {
// feedback is a helper function to print the payload to a file or STDOUT or keep quiet
// due to the value of flag "quiet" and "output".
func feedback(t *tufCommander, payload []byte) error {
// We only get here when everythings goes well, since the flag "quiet" was
// We only get here when everything goes well, since the flag "quiet" was
// provided, we output nothing but just return.
if t.quiet {
return nil
}

// Flag "quiet" was not "true", that's why we get here.
if t.output != "" {
if err := ioutil.WriteFile(t.output, payload, 0644); err != nil {
return err
}
return ioutil.WriteFile(t.output, payload, 0644)
}

os.Stdout.Write(payload)
Expand Down

0 comments on commit 31a5ebc

Please sign in to comment.