From a2004de4a594965cdf0e966da8e726a9bd71c098 Mon Sep 17 00:00:00 2001 From: Patrick Huck Date: Tue, 22 Jun 2021 14:49:39 -0700 Subject: [PATCH] client: catch invalid timeout value --- .../mpcontribs/client/__init__.py | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mpcontribs-client/mpcontribs/client/__init__.py b/mpcontribs-client/mpcontribs/client/__init__.py index 40f748346..fe6f254ca 100644 --- a/mpcontribs-client/mpcontribs/client/__init__.py +++ b/mpcontribs-client/mpcontribs/client/__init__.py @@ -1307,11 +1307,13 @@ def download_contributions( ndownloads = 0 for name, values in all_ids.items(): - timeout -= time.perf_counter() - start - if timeout < 1: - return ndownloads + if timeout > 0: + timeout -= time.perf_counter() - start + if timeout < 1: + return ndownloads + + start = time.perf_counter() - start = time.perf_counter() cids = list(values["ids"]) paths, per_page = self._download_resource( resource="contributions", ids=cids, fmt=fmt, @@ -1326,11 +1328,13 @@ def download_contributions( print(f"No new contributions to download for '{name}'.") for component in components: - timeout -= time.perf_counter() - start - if timeout < 1: - return ndownloads + if timeout > 0: + timeout -= time.perf_counter() - start + if timeout < 1: + return ndownloads + + start = time.perf_counter() - start = time.perf_counter() ids = list(values[component]["ids"]) paths, per_page = self._download_resource( resource=component, ids=ids, fmt=fmt,