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

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