dcavalca / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

Blame SOURCES/0009-Fix-reporting-irrecoverable-errors-on-packages-downl.patch

39dbb9
From f5cb86b83aedaa18fd784d06d8f1479b9127c6f5 Mon Sep 17 00:00:00 2001
39dbb9
From: Marek Blaha <mblaha@redhat.com>
39dbb9
Date: Wed, 6 Oct 2021 09:43:37 +0200
39dbb9
Subject: [PATCH] Fix reporting irrecoverable errors on packages download
39dbb9
39dbb9
The original _irrecoverable property returns random dictionary - either
39dbb9
packages irrecoverable errors, or global fatal error or even new empty
39dbb9
dictionary. This makes it prone to programmer errors like:
39dbb9
39dbb9
errs._irrecoverable[pkg] = [err]
39dbb9
39dbb9
which may lead to setting the error into the newly created empty
39dbb9
dictionary instead of packages errors dictionary as intended.
39dbb9
39dbb9
I turned the property to method which I consider more clear.
39dbb9
---
52b19a
 dnf/base.py | 8 ++++----
52b19a
 dnf/repo.py | 9 ++++-----
39dbb9
 2 files changed, 8 insertions(+), 9 deletions(-)
39dbb9
39dbb9
diff --git a/dnf/base.py b/dnf/base.py
52b19a
index 0949ddf8..b0a378c2 100644
39dbb9
--- a/dnf/base.py
39dbb9
+++ b/dnf/base.py
39dbb9
@@ -1165,8 +1165,8 @@ class Base(object):
39dbb9
                 progress.start(len(payloads), est_remote_size)
39dbb9
             errors = dnf.repo._download_payloads(payloads, drpm)
39dbb9
 
39dbb9
-            if errors._irrecoverable:
39dbb9
-                raise dnf.exceptions.DownloadError(errors._irrecoverable)
39dbb9
+            if errors._irrecoverable():
39dbb9
+                raise dnf.exceptions.DownloadError(errors._irrecoverable())
39dbb9
 
39dbb9
             remote_size = sum(errors._bandwidth_used(pload)
39dbb9
                               for pload in payloads)
39dbb9
@@ -1191,8 +1191,8 @@ class Base(object):
39dbb9
                 progress.start(len(payloads), est_remote_size)
39dbb9
                 errors = dnf.repo._download_payloads(payloads, drpm)
39dbb9
 
39dbb9
-                if errors._irrecoverable:
39dbb9
-                    raise dnf.exceptions.DownloadError(errors._irrecoverable)
39dbb9
+                if errors._irrecoverable():
39dbb9
+                    raise dnf.exceptions.DownloadError(errors._irrecoverable())
39dbb9
 
39dbb9
                 remote_size += \
39dbb9
                     sum(errors._bandwidth_used(pload) for pload in payloads)
39dbb9
diff --git a/dnf/repo.py b/dnf/repo.py
52b19a
index b5c9849e..b454e981 100644
39dbb9
--- a/dnf/repo.py
39dbb9
+++ b/dnf/repo.py
39dbb9
@@ -112,7 +112,7 @@ def _download_payloads(payloads, drpm):
39dbb9
             errs._skipped.add(pkg)
39dbb9
             continue
39dbb9
         pkg.repo._repo.expire()
39dbb9
-        errs._irrecoverable[pkg] = [err]
39dbb9
+        errs._pkg_irrecoverable[pkg] = [err]
39dbb9
 
39dbb9
     return errs
39dbb9
 
39dbb9
@@ -131,15 +131,14 @@ def _update_saving(saving, payloads, errs):
39dbb9
 
39dbb9
 class _DownloadErrors(object):
39dbb9
     def __init__(self):
39dbb9
-        self._val_irrecoverable = {}
39dbb9
+        self._pkg_irrecoverable = {}
39dbb9
         self._val_recoverable = {}
39dbb9
         self._fatal = None
39dbb9
         self._skipped = set()
39dbb9
 
39dbb9
-    @property
39dbb9
     def _irrecoverable(self):
39dbb9
-        if self._val_irrecoverable:
39dbb9
-            return self._val_irrecoverable
39dbb9
+        if self._pkg_irrecoverable:
39dbb9
+            return self._pkg_irrecoverable
39dbb9
         if self._fatal:
39dbb9
             return {'': [self._fatal]}
39dbb9
         return {}
52b19a
-- 
52b19a
2.35.1
39dbb9