diff --git a/http/download.go b/http/download.go index 6a20f64b..447b35cd 100644 --- a/http/download.go +++ b/http/download.go @@ -218,20 +218,18 @@ func DownloadTempWithChecksum(downloader aptly.Downloader, url string, expected if expected.Size != -1 && downloader.GetProgress() != nil { downloader.GetProgress().InitBar(expected.Size, true) + defer downloader.GetProgress().ShutdownBar() } ch := make(chan error, 1) downloader.DownloadWithChecksum(url, tempfile, ch, expected, ignoreMismatch) err = <-ch + if err != nil { return nil, err } - if expected.Size != -1 && downloader.GetProgress() != nil { - downloader.GetProgress().ShutdownBar() - } - file, err := os.Open(tempfile) if err != nil { return nil, err