1
0
mirror of https://github.com/docker/docs.git synced 2026-11-05 00:14:17 +03:00

From riyazdf's review

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 <hukeping@huawei.com>
This commit is contained in:
HuKeping
2016-05-10 09:47:33 +08:00
parent 0f5d22f95f
commit 31a5ebcf4b

View File

@@ -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)
@@ -33,7 +33,7 @@ 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
@@ -41,9 +41,7 @@ func feedback(t *tufCommander, payload []byte) error {
// 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)