Skip to content

Commit

Permalink
conf: introduce 'retries' option
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Hatina authored and MichaelMraka committed Sep 13, 2016
1 parent 8da4640 commit 9ed52cc
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
18 changes: 13 additions & 5 deletions dnf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,11 +931,15 @@ def download_packages(self, pkglist, progress=None, callback_total=None):
remote_size = sum(errors._bandwidth_used(pload)
for pload in payloads)
saving = dnf.repo._update_saving((0, 0), payloads,
errors._recoverable)
errors._recoverable)

if errors._recoverable:
msg = dnf.exceptions.DownloadError.errmap2str(
errors._recoverable)
retries = self.conf.retries
forever = retries == 0
while errors._recoverable and (forever or retries > 0):
if retries > 0:
retries -= 1

msg = _("Some packages were not downloaded. Retrying.")
logger.info(msg)

remaining_pkgs = [pkg for pkg in errors._recoverable]
Expand All @@ -947,14 +951,18 @@ def download_packages(self, pkglist, progress=None, callback_total=None):
progress.start(len(payloads), est_remote_size)
errors = dnf.repo._download_payloads(payloads, drpm)

assert not errors._recoverable
if errors._irrecoverable:
raise dnf.exceptions.DownloadError(errors._irrecoverable)

remote_size += \
sum(errors._bandwidth_used(pload) for pload in payloads)
saving = dnf.repo._update_saving(saving, payloads, {})

if errors._recoverable:
msg = dnf.exceptions.DownloadError.errmap2str(
errors._recoverable)
logger.info(msg)

if callback_total is not None:
callback_total(remote_size, beg_download)

Expand Down
2 changes: 2 additions & 0 deletions dnf/conf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ def __init__(self, section='main', parser=None):
ListOption([dnf.const.PLUGINCONFPATH])) # :api
self._add_option('persistdir', PathOption(dnf.const.PERSISTDIR)) # :api
self._add_option('recent', IntOption(7, range_min=0))
self._add_option('retries', PositiveIntOption(10, names_of_0=["0"]))
self._add_option('reset_nice', BoolOption(True))

self._add_option('cachedir', PathOption(cachedir)) # :api
Expand Down Expand Up @@ -913,6 +914,7 @@ def __init__(self, parent, section=None, parser=None):
inherit(parent._get_option('repo_gpgcheck')))
self._add_option('enablegroups',
inherit(parent._get_option('enablegroups')))
self._add_option('retries', inherit(parent._get_option('retries')))

self._add_option('bandwidth', inherit(parent._get_option('bandwidth')))
self._add_option('minrate', inherit(parent._get_option('minrate')))
Expand Down
4 changes: 4 additions & 0 deletions doc/api_conf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ Configurable settings of the :class:`dnf.Base` object are stored into a :class:`

List of directories to search for repo configuration files. Has a reasonable default commonly used on the given distribution.

.. attribute:: retries

Number of times any attempt to retrieve a file should retry before returning an error. Setting this to `0' makes it try forever. Defaults to `10'.

.. attribute:: sslcacert

Path to the directory or file containing the certificate authorities to verify SSL certificates.
Expand Down
12 changes: 12 additions & 0 deletions doc/conf_ref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ or :ref:`mirrorlist <mirrorlist-label>` option definition.

The priority value of this repository, default is 99. If there is more than one candidate package for a particular operation, the one from a repo with *the lowest priority value* is picked, possibly despite being less convenient otherwise (e.g. by being a lower version).

.. _retries-label:

``retries``
:ref:`integer <integer-label>`

Overrides the retries option from the [main] section for this repository.

.. _skip_if_unavailable-label:

``skip_if_unavailable``
Expand Down Expand Up @@ -399,6 +406,11 @@ configuration.

Whether to perform GPG signature check on this repository's metadata. The default is False.

``retries``
:ref:`integer <integer-label>`

Set the number of times any attempt to retrieve a file should retry before returning an error. Setting this to `0' makes dnf try forever. Default is `10'.

.. _sslcacert-label:

``sslcacert``
Expand Down

0 comments on commit 9ed52cc

Please sign in to comment.