Skip to content

Commit

Permalink
Merge pull request #5000 from tstromberg/pbar
Browse files Browse the repository at this point in the history
Use a temp dest to atomically download the iso
  • Loading branch information
tstromberg committed Aug 7, 2019
2 parents 551b164 + 08d97cf commit a8752f1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/util/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -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
Expand Down

0 comments on commit a8752f1

Please sign in to comment.