Use a temp dest to atomically download the iso

pull/5000/head
tstromberg 2019-08-06 16:01:06 -07:00
parent 551b164017
commit 08d97cf025
1 changed files with 6 additions and 2 deletions

View File

@ -65,10 +65,14 @@ func (f DefaultDownloader) CacheMinikubeISOFromURL(url string) error {
urlWithChecksum = url + "?checksum=file:" + constants.DefaultISOSHAURL
}
dst := f.GetISOCacheFilepath(url)
// Predictable temp destination so that resume can function
tmpDst := dst + ".download"
opts := []getter.ClientOption{getter.WithProgress(defaultProgressBar)}
client := &getter.Client{
Src: urlWithChecksum,
Dst: f.GetISOCacheFilepath(url),
Dst: tmpDst,
Mode: getter.ClientModeFile,
Options: opts,
}
@ -78,7 +82,7 @@ func (f DefaultDownloader) CacheMinikubeISOFromURL(url string) error {
if err := client.Get(); err != nil {
return errors.Wrap(err, url)
}
return nil
return os.Rename(tmpDst, dst)
}
// ShouldCacheMinikubeISO returns if we need to download the ISO