common: return -1 download percent if download hasn't started [GH-288]
This commit is contained in:
parent
62b87ee472
commit
71664cb34e
@ -20,6 +20,13 @@ IMPROVEMENTS:
|
||||
only check at execution.
|
||||
* command/build: A path of "-" will read the template from stdin.
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
* builder/virtualbox: dowload progress won't be shown until download
|
||||
actually starts. [GH-288]
|
||||
* builder/vmware: dowload progress won't be shown until download
|
||||
actually starts. [GH-288]
|
||||
|
||||
## 0.3.1 (August 12, 2013)
|
||||
|
||||
IMPROVEMENTS:
|
||||
|
@ -69,7 +69,10 @@ DownloadWaitLoop:
|
||||
|
||||
break DownloadWaitLoop
|
||||
case <-progressTicker.C:
|
||||
ui.Message(fmt.Sprintf("Download progress: %d%%", download.PercentProgress()))
|
||||
progress := download.PercentProgress()
|
||||
if progress >= 0 {
|
||||
ui.Message(fmt.Sprintf("Download progress: %d%%", progress))
|
||||
}
|
||||
case <-time.After(1 * time.Second):
|
||||
if _, ok := state[multistep.StateCancelled]; ok {
|
||||
ui.Say("Interrupt received. Cancelling download...")
|
||||
|
@ -71,7 +71,10 @@ DownloadWaitLoop:
|
||||
|
||||
break DownloadWaitLoop
|
||||
case <-progressTicker.C:
|
||||
ui.Say(fmt.Sprintf("Download progress: %d%%", download.PercentProgress()))
|
||||
progress := download.PercentProgress()
|
||||
if progress >= 0 {
|
||||
ui.Message(fmt.Sprintf("Download progress: %d%%", progress))
|
||||
}
|
||||
case <-time.After(1 * time.Second):
|
||||
if _, ok := state[multistep.StateCancelled]; ok {
|
||||
ui.Say("Interrupt received. Cancelling download...")
|
||||
|
@ -148,12 +148,12 @@ func (d *DownloadClient) Get() (string, error) {
|
||||
}
|
||||
|
||||
// PercentProgress returns the download progress as a percentage.
|
||||
func (d *DownloadClient) PercentProgress() uint {
|
||||
func (d *DownloadClient) PercentProgress() int {
|
||||
if d.downloader == nil {
|
||||
return 0
|
||||
return -1
|
||||
}
|
||||
|
||||
return uint((float64(d.downloader.Progress()) / float64(d.downloader.Total())) * 100)
|
||||
return int((float64(d.downloader.Progress()) / float64(d.downloader.Total())) * 100)
|
||||
}
|
||||
|
||||
// VerifyChecksum tests that the path matches the checksum for the
|
||||
|
Loading…
x
Reference in New Issue
Block a user