richardphibel / rpms / libdnf

Forked from rpms/libdnf 2 years ago
Clone

Blame SOURCES/0008-Revert-Fix-load-update-FailSafe.patch

aea1e4
From 140168ce29d2425ebf2b4b5b25926611a189cd84 Mon Sep 17 00:00:00 2001
aea1e4
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
aea1e4
Date: Sun, 25 Apr 2021 19:47:53 +0200
aea1e4
Subject: [PATCH 08/19] Revert "Fix load/update FailSafe"
aea1e4
aea1e4
This reverts commit 244a37d772fcd5a5969085edab544fb1e7b68aad.
aea1e4
---
aea1e4
 libdnf/module/ModulePackageContainer.cpp | 38 ++++++++++++++++++------
aea1e4
 1 file changed, 29 insertions(+), 9 deletions(-)
aea1e4
aea1e4
diff --git a/libdnf/module/ModulePackageContainer.cpp b/libdnf/module/ModulePackageContainer.cpp
aea1e4
index e19db08b..97c84c01 100644
aea1e4
--- a/libdnf/module/ModulePackageContainer.cpp
aea1e4
+++ b/libdnf/module/ModulePackageContainer.cpp
aea1e4
@@ -1641,7 +1641,6 @@ ModulePackageContainer::Impl::ModulePersistor::getRemovedProfiles()
aea1e4
 
aea1e4
 void ModulePackageContainer::loadFailSafeData()
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     auto persistor = pImpl->persistor->configs;
aea1e4
 
aea1e4
     std::map<std::string, std::pair<std::string, bool>> enabledStreams;
aea1e4
@@ -1696,21 +1695,42 @@ void ModulePackageContainer::loadFailSafeData()
aea1e4
 
aea1e4
 std::vector<ModulePackage *> ModulePackageContainer::Impl::getLatestActiveEnabledModules()
aea1e4
 {
aea1e4
-    Query query(moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
aea1e4
-    query.addFilter(HY_PKG, HY_EQ, activatedModules.get());
aea1e4
-    query.addFilter(HY_PKG_REPONAME, HY_NEQ, HY_SYSTEM_REPO_NAME);
aea1e4
-    query.addFilter(HY_PKG_LATEST_PER_ARCH, HY_EQ, 1);
aea1e4
-    auto set = query.runSet();
aea1e4
-
aea1e4
     std::vector<ModulePackage *> activeModules;
aea1e4
     Id moduleId = -1;
aea1e4
-    while ((moduleId = set->next(moduleId)) != -1) {
aea1e4
+    while ((moduleId = activatedModules->next(moduleId)) != -1) {
aea1e4
         auto modulePackage = modules.at(moduleId).get();
aea1e4
         if (isEnabled(modulePackage->getName(), modulePackage->getStream())) {
aea1e4
             activeModules.push_back(modulePackage);
aea1e4
         }
aea1e4
     }
aea1e4
-    return activeModules;
aea1e4
+    if (activeModules.empty()) {
aea1e4
+        return {};
aea1e4
+    }
aea1e4
+    auto sack = moduleSack;
aea1e4
+    std::sort(activeModules.begin(), activeModules.end(),
aea1e4
+              [sack](const ModulePackage * first, const ModulePackage * second)
aea1e4
+              {return modulePackageLatestSorter(sack, first, second);});
aea1e4
+
aea1e4
+    auto packageFirst = activeModules[0];
aea1e4
+    std::vector<ModulePackage *> latest;
aea1e4
+    auto vectorSize = activeModules.size();
aea1e4
+    latest.push_back(packageFirst);
aea1e4
+    auto name = packageFirst->getNameCStr();
aea1e4
+    auto stream = packageFirst->getStreamCStr();
aea1e4
+    auto arch = packageFirst->getArchCStr();
aea1e4
+
aea1e4
+    for (unsigned int index = 1; index < vectorSize; ++index) {
aea1e4
+        auto & package = activeModules[index];
aea1e4
+        if (g_strcmp0(package->getNameCStr(), name) != 0 ||
aea1e4
+            g_strcmp0(package->getStreamCStr(), stream) != 0 ||
aea1e4
+            g_strcmp0(package->getArchCStr(), arch) != 0) {
aea1e4
+            name = package->getNameCStr();
aea1e4
+            stream = package->getStreamCStr();
aea1e4
+            arch = package->getArchCStr();
aea1e4
+            latest.push_back(package);
aea1e4
+        }
aea1e4
+    }
aea1e4
+    return latest;
aea1e4
 }
aea1e4
 
aea1e4
 void ModulePackageContainer::Impl::addVersion2Modules()
aea1e4
-- 
aea1e4
2.31.1
aea1e4