Commit 71664cb3 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

common: return -1 download percent if download hasn't started [GH-288]

parent 62b87ee4
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment