Must verify success of from-network copy during upgrade (ref #1138)

This commit is contained in:
Jakob Borg 2014-12-22 10:42:47 +01:00
parent 7344a6205f
commit 23085eb5ae
1 changed files with 13 additions and 5 deletions

View File

@ -120,9 +120,6 @@ func readTarGZ(url string, dir string) (string, error) {
}
tr := tar.NewReader(gr)
if err != nil {
return "", err
}
// Iterate through the files in the archive.
for {
@ -143,14 +140,25 @@ func readTarGZ(url string, dir string) (string, error) {
if err != nil {
return "", err
}
io.Copy(of, tr)
_, err = io.Copy(of, tr)
if err != nil {
os.Remove(of.Name())
return "", err
}
err = of.Close()
if err != nil {
os.Remove(of.Name())
return "", err
}
os.Chmod(of.Name(), os.FileMode(hdr.Mode))
err = os.Chmod(of.Name(), os.FileMode(hdr.Mode))
if err != nil {
os.Remove(of.Name())
return "", err
}
return of.Name(), nil
}
}