mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-05 22:08:27 +00:00
Fix issues with progress == nil causing panics
Part of PR #459 This prepares for more methods to be exposed via the API.
This commit is contained in:
committed by
Oliver Sauder
parent
98e75f6d97
commit
769e984ef4
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -53,11 +54,16 @@ func NewDownloader(downLimit int64, maxTries int, progress aptly.Progress) aptly
|
||||
},
|
||||
}
|
||||
|
||||
progressWriter := io.Writer(progress)
|
||||
if progress == nil {
|
||||
progressWriter = ioutil.Discard
|
||||
}
|
||||
|
||||
downloader.client.CheckRedirect = downloader.checkRedirect
|
||||
if downLimit > 0 {
|
||||
downloader.aggWriter = flowrate.NewWriter(progress, downLimit)
|
||||
downloader.aggWriter = flowrate.NewWriter(progressWriter, downLimit)
|
||||
} else {
|
||||
downloader.aggWriter = progress
|
||||
downloader.aggWriter = progressWriter
|
||||
}
|
||||
|
||||
return downloader
|
||||
|
||||
Reference in New Issue
Block a user