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

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