mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-04 05:10:40 +00:00
Rework HTTP downloader retry logic
Apply retries as global, config-level option `downloadRetries` so that it can be applied to any aptly command which downloads objects. Unwrap `errors.Wrap` which is used in downloader. Unwrap `*url.Error` which should be the actual error returned from the HTTP client, catch more cases, be more specific around failures.
This commit is contained in:
committed by
Andrey Smirnov
parent
2e7f624b34
commit
f0a370db24
+9
-1
@@ -213,7 +213,15 @@ func (context *AptlyContext) Downloader() aptly.Downloader {
|
||||
if downloadLimit == 0 {
|
||||
downloadLimit = context.config().DownloadLimit
|
||||
}
|
||||
context.downloader = http.NewDownloader(downloadLimit*1024, context._progress())
|
||||
maxTries := context.config().DownloadRetries + 1
|
||||
maxTriesFlag := context.flags.Lookup("max-tries")
|
||||
if maxTriesFlag != nil {
|
||||
maxTriesFlagValue := maxTriesFlag.Value.Get().(int)
|
||||
if maxTriesFlagValue > maxTries {
|
||||
maxTries = maxTriesFlagValue
|
||||
}
|
||||
}
|
||||
context.downloader = http.NewDownloader(downloadLimit*1024, maxTries, context._progress())
|
||||
}
|
||||
|
||||
return context.downloader
|
||||
|
||||
Reference in New Issue
Block a user