From f9c58e2b1f42a7aef855fecfd89a5e122335633f Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Thu, 6 Sep 2018 16:38:28 +0200 Subject: [PATCH] download: defer progress bar Finish --- common/download.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/download.go b/common/download.go index 508f15c24..0d3e9fc0e 100644 --- a/common/download.go +++ b/common/download.go @@ -317,6 +317,7 @@ func (d *HTTPDownloader) Download(dst *os.File, src *url.URL) error { bar := d.ProgressBar() bar.Start(total) + defer bar.Finish() bar.Add(current) body := bar.NewProxyReader(resp.Body) @@ -336,7 +337,6 @@ func (d *HTTPDownloader) Download(dst *os.File, src *url.URL) error { break } } - bar.Finish() return nil } @@ -430,6 +430,7 @@ func (d *FileDownloader) Download(dst *os.File, src *url.URL) error { bar := d.ProgressBar() bar.Start(uint64(fi.Size())) + defer bar.Finish() fProxy := bar.NewProxyReader(f) // no bufferSize specified, so copy synchronously. @@ -455,7 +456,6 @@ func (d *FileDownloader) Download(dst *os.File, src *url.URL) error { // ...and we spin until it's done err = <-errch } - bar.Finish() return err } @@ -532,6 +532,7 @@ func (d *SMBDownloader) Download(dst *os.File, src *url.URL) error { bar := d.ProgressBar() bar.Start(uint64(fi.Size())) + defer bar.Finish() fProxy := bar.NewProxyReader(f) // no bufferSize specified, so copy synchronously. @@ -557,7 +558,6 @@ func (d *SMBDownloader) Download(dst *os.File, src *url.URL) error { // ...and as usual we spin until it's done err = <-errch } - bar.Finish() return err }