Use a temp dest to atomically download the iso
parent
551b164017
commit
08d97cf025
|
@ -65,10 +65,14 @@ func (f DefaultDownloader) CacheMinikubeISOFromURL(url string) error {
|
||||||
urlWithChecksum = url + "?checksum=file:" + constants.DefaultISOSHAURL
|
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)}
|
opts := []getter.ClientOption{getter.WithProgress(defaultProgressBar)}
|
||||||
client := &getter.Client{
|
client := &getter.Client{
|
||||||
Src: urlWithChecksum,
|
Src: urlWithChecksum,
|
||||||
Dst: f.GetISOCacheFilepath(url),
|
Dst: tmpDst,
|
||||||
Mode: getter.ClientModeFile,
|
Mode: getter.ClientModeFile,
|
||||||
Options: opts,
|
Options: opts,
|
||||||
}
|
}
|
||||||
|
@ -78,7 +82,7 @@ func (f DefaultDownloader) CacheMinikubeISOFromURL(url string) error {
|
||||||
if err := client.Get(); err != nil {
|
if err := client.Get(); err != nil {
|
||||||
return errors.Wrap(err, url)
|
return errors.Wrap(err, url)
|
||||||
}
|
}
|
||||||
return nil
|
return os.Rename(tmpDst, dst)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShouldCacheMinikubeISO returns if we need to download the ISO
|
// ShouldCacheMinikubeISO returns if we need to download the ISO
|
||||||
|
|
Loading…
Reference in New Issue