From eff7e688e2f1ad5d10a5ed05948c08141083f316 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= <lhrazky@redhat.com>
Date: Mon, 20 Jun 2022 16:02:11 +0200
Subject: [PATCH] Gracefully handle failure to open repo primary file

Reference:https://github.com/rpm-software-management/libdnf/commit/eff7e688e2f1ad5d10a5ed05948c08141083f316
Conflict:NA

---
 libdnf/dnf-sack.cpp | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/libdnf/dnf-sack.cpp b/libdnf/dnf-sack.cpp
index a88e8a1..a89fc15 100644
--- a/libdnf/dnf-sack.cpp
+++ b/libdnf/dnf-sack.cpp
@@ -718,7 +718,15 @@ load_yum_repo(DnfSack *sack, HyRepo hrepo, GError **error)
             goto out;
         }
         fp_primary = solv_xfopen(primary.c_str(), "r");
-        assert(fp_primary);
+        if (fp_primary == 0) {
+            g_set_error(error,
+                        DNF_ERROR,
+                        DNF_ERROR_INTERNAL_ERROR,
+                        _("Opening repository primary data has failed: %s"),
+                        strerror(errno));
+            retval = FALSE;
+            goto out;
+        }
 
         g_debug("fetching %s", name);
         if (repo_add_repomdxml(repo, fp_repomd, 0) || \
-- 
2.23.0

