浏览代码

Merge pull request #21193 from amitkris/flush_fix

Remove flush(stdout) in pkg/chrootarchive/diff_unix.go
Antonio Murdaca 9 年之前
父节点
当前提交
6852d87659
共有 3 个文件被更改,包括 10 次插入5 次删除
  1. 4 1
      pkg/chrootarchive/archive_unix.go
  2. 4 2
      pkg/chrootarchive/diff_unix.go
  3. 2 2
      pkg/chrootarchive/init_unix.go

+ 4 - 1
pkg/chrootarchive/archive_unix.go

@@ -46,7 +46,10 @@ func untar() {
 		fatal(err)
 		fatal(err)
 	}
 	}
 	// fully consume stdin in case it is zero padded
 	// fully consume stdin in case it is zero padded
-	flush(os.Stdin)
+	if _, err := flush(os.Stdin); err != nil {
+		fatal(err)
+	}
+
 	os.Exit(0)
 	os.Exit(0)
 }
 }
 
 

+ 4 - 2
pkg/chrootarchive/diff_unix.go

@@ -65,8 +65,10 @@ func applyLayer() {
 		fatal(fmt.Errorf("unable to encode layerSize JSON: %s", err))
 		fatal(fmt.Errorf("unable to encode layerSize JSON: %s", err))
 	}
 	}
 
 
-	flush(os.Stdout)
-	flush(os.Stdin)
+	if _, err := flush(os.Stdin); err != nil {
+		fatal(err)
+	}
+
 	os.Exit(0)
 	os.Exit(0)
 }
 }
 
 

+ 2 - 2
pkg/chrootarchive/init_unix.go

@@ -23,6 +23,6 @@ func fatal(err error) {
 
 
 // flush consumes all the bytes from the reader discarding
 // flush consumes all the bytes from the reader discarding
 // any errors
 // any errors
-func flush(r io.Reader) {
-	io.Copy(ioutil.Discard, r)
+func flush(r io.Reader) (bytes int64, err error) {
+	return io.Copy(ioutil.Discard, r)
 }
 }