Skip to content

Commit

Permalink
Merge pull request #3961 from afbjorklund/tarball-tmp
Browse files Browse the repository at this point in the history
Use a temp file, when writing the cached image
  • Loading branch information
tstromberg authored Mar 26, 2019
2 parents a131747 + 3194ec7 commit 4ccc7a2
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pkg/minikube/machine/cache_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,21 @@ func CacheImage(image, dst string) error {
}

glog.Infoln("OPENING: ", dstPath)
f, err := os.Create(dstPath)
f, err := ioutil.TempFile(filepath.Dir(dstPath), filepath.Base(dstPath)+".*.tmp")
if err != nil {
return err
}
defer f.Close()
return tarball.Write(tag, img, nil, f)
err = tarball.Write(tag, img, nil, f)
if err != nil {
return err
}
err = f.Close()
if err != nil {
return err
}
err = os.Rename(f.Name(), dstPath)
if err != nil {
return err
}
return nil
}

0 comments on commit 4ccc7a2

Please sign in to comment.