Progress when downloading single files and when parsing remote mirrors.

This commit is contained in:
Andrey Smirnov
2014-03-07 00:37:06 +04:00
parent 04d6603f38
commit 74c88f3ef6
5 changed files with 37 additions and 0 deletions

View File

@@ -85,6 +85,11 @@ func (downloader *downloaderImpl) Resume() {
}
}
// GetProgress returns Progress object
func (downloader *downloaderImpl) GetProgress() aptly.Progress {
return downloader.progress
}
// Download starts new download task
func (downloader *downloaderImpl) Download(url string, destination string, result chan<- error) {
downloader.DownloadWithChecksum(url, destination, result, utils.ChecksumInfo{Size: -1}, false)
@@ -211,6 +216,10 @@ func DownloadTempWithChecksum(downloader aptly.Downloader, url string, expected
tempfile := filepath.Join(tempdir, "buffer")
if expected.Size != -1 && downloader.GetProgress() != nil {
downloader.GetProgress().InitBar(expected.Size, true)
}
ch := make(chan error, 1)
downloader.DownloadWithChecksum(url, tempfile, ch, expected, ignoreMismatch)
@@ -219,6 +228,10 @@ func DownloadTempWithChecksum(downloader aptly.Downloader, url string, expected
return nil, err
}
if expected.Size != -1 && downloader.GetProgress() != nil {
downloader.GetProgress().ShutdownBar()
}
file, err := os.Open(tempfile)
if err != nil {
return nil, err

View File

@@ -130,3 +130,8 @@ func (f *FakeDownloader) Pause() {
// Resume does nothing
func (f *FakeDownloader) Resume() {
}
// GetProgress returns Progress object
func (f *FakeDownloader) GetProgress() aptly.Progress {
return nil
}