build: simplify Close logic in WriteTempDockerfile

Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
Tibor Vass 2018-06-09 01:16:51 +00:00
parent ed75f6202b
commit 15674d9ee9
1 changed files with 2 additions and 6 deletions

View File

@ -111,12 +111,8 @@ func WriteTempDockerfile(rc io.ReadCloser) (string, error) {
if err != nil {
return "", err
}
_, err = io.Copy(f, rc)
if err != nil {
f.Close()
return "", err
}
if err := f.Close(); err != nil {
defer f.Close()
if _, err := io.Copy(f, rc); err != nil {
return "", err
}
return dockerfileDir, rc.Close()