download: defer progress bar Finish

This commit is contained in:
Adrien Delorme 2018-09-06 16:38:28 +02:00
parent 3842f85eb4
commit f9c58e2b1f
1 changed files with 3 additions and 3 deletions

View File

@ -317,6 +317,7 @@ func (d *HTTPDownloader) Download(dst *os.File, src *url.URL) error {
bar := d.ProgressBar() bar := d.ProgressBar()
bar.Start(total) bar.Start(total)
defer bar.Finish()
bar.Add(current) bar.Add(current)
body := bar.NewProxyReader(resp.Body) body := bar.NewProxyReader(resp.Body)
@ -336,7 +337,6 @@ func (d *HTTPDownloader) Download(dst *os.File, src *url.URL) error {
break break
} }
} }
bar.Finish()
return nil return nil
} }
@ -430,6 +430,7 @@ func (d *FileDownloader) Download(dst *os.File, src *url.URL) error {
bar := d.ProgressBar() bar := d.ProgressBar()
bar.Start(uint64(fi.Size())) bar.Start(uint64(fi.Size()))
defer bar.Finish()
fProxy := bar.NewProxyReader(f) fProxy := bar.NewProxyReader(f)
// no bufferSize specified, so copy synchronously. // 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 // ...and we spin until it's done
err = <-errch err = <-errch
} }
bar.Finish()
return err return err
} }
@ -532,6 +532,7 @@ func (d *SMBDownloader) Download(dst *os.File, src *url.URL) error {
bar := d.ProgressBar() bar := d.ProgressBar()
bar.Start(uint64(fi.Size())) bar.Start(uint64(fi.Size()))
defer bar.Finish()
fProxy := bar.NewProxyReader(f) fProxy := bar.NewProxyReader(f)
// no bufferSize specified, so copy synchronously. // 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 // ...and as usual we spin until it's done
err = <-errch err = <-errch
} }
bar.Finish()
return err return err
} }