Skip to content

Commit

Permalink
Use a temp file, when writing the cached image
Browse files Browse the repository at this point in the history
  • Loading branch information
afbjorklund committed Mar 25, 2019
1 parent 5434880 commit 3194ec7
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 3194ec7

Please sign in to comment.