Blame SOURCES/0010-Revert-Call-addVersion2Modules-as-late-as-possible.patch

aea1e4
From 058b6112374f5feb5ee57488ac3fdbc7666a2016 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 10/19] Revert "Call addVersion2Modules(); as late as possible"
aea1e4
aea1e4
This reverts commit fe27dba67384e549a3be2a91c4a6cf1151113157.
aea1e4
---
aea1e4
 libdnf/module/ModulePackageContainer.cpp | 28 +++---------------------
aea1e4
 1 file changed, 3 insertions(+), 25 deletions(-)
aea1e4
aea1e4
diff --git a/libdnf/module/ModulePackageContainer.cpp b/libdnf/module/ModulePackageContainer.cpp
aea1e4
index 893b839a..6ee2b68f 100644
aea1e4
--- a/libdnf/module/ModulePackageContainer.cpp
aea1e4
+++ b/libdnf/module/ModulePackageContainer.cpp
aea1e4
@@ -346,6 +346,7 @@ ModulePackageContainer::add(DnfSack * sack)
aea1e4
                             exception.what()));
aea1e4
         }
aea1e4
     }
aea1e4
+    pImpl->addVersion2Modules();
aea1e4
 }
aea1e4
 
aea1e4
 void ModulePackageContainer::addDefaultsFromDisk()
aea1e4
@@ -427,7 +428,6 @@ void ModulePackageContainer::createConflictsBetweenStreams()
aea1e4
 
aea1e4
 bool ModulePackageContainer::empty() const noexcept
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     return pImpl->modules.empty();
aea1e4
 }
aea1e4
 
aea1e4
@@ -521,13 +521,11 @@ bool ModulePackageContainer::isDisabled(const ModulePackage * module)
aea1e4
 std::vector<std::string> ModulePackageContainer::getDefaultProfiles(std::string moduleName,
aea1e4
     std::string moduleStream)
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     return pImpl->moduleMetadata.getDefaultProfiles(moduleName, moduleStream);
aea1e4
 }
aea1e4
 
aea1e4
 const std::string & ModulePackageContainer::getDefaultStream(const std::string &name) const
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     auto it = pImpl->moduleDefaults.find(name);
aea1e4
     if (it == pImpl->moduleDefaults.end()) {
aea1e4
         return EMPTY_RESULT;
aea1e4
@@ -537,7 +535,6 @@ const std::string & ModulePackageContainer::getDefaultStream(const std::string &
aea1e4
 
aea1e4
 const std::string & ModulePackageContainer::getEnabledStream(const std::string &name)
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     return pImpl->persistor->getStream(name);
aea1e4
 }
aea1e4
 
aea1e4
@@ -547,7 +544,6 @@ const std::string & ModulePackageContainer::getEnabledStream(const std::string &
aea1e4
 bool
aea1e4
 ModulePackageContainer::enable(const std::string &name, const std::string & stream, const bool count)
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     if (count) {
aea1e4
         pImpl->persistor->getEntry(name).second.streamChangesNum++;
aea1e4
     }
aea1e4
@@ -573,7 +569,6 @@ ModulePackageContainer::enable(const ModulePackage * module, const bool count)
aea1e4
  */
aea1e4
 void ModulePackageContainer::disable(const std::string & name, const bool count)
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     if (count) {
aea1e4
         pImpl->persistor->getEntry(name).second.streamChangesNum++;
aea1e4
     }
aea1e4
@@ -594,11 +589,11 @@ void ModulePackageContainer::disable(const ModulePackage * module, const bool co
aea1e4
  */
aea1e4
 void ModulePackageContainer::reset(const std::string & name, const bool count)
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     if (count) {
aea1e4
         pImpl->persistor->getEntry(name).second.streamChangesNum++;
aea1e4
     }
aea1e4
     pImpl->persistor->changeState(name, ModuleState::UNKNOWN);
aea1e4
+
aea1e4
     pImpl->persistor->changeStream(name, "");
aea1e4
     auto & profiles = pImpl->persistor->getEntry(name).second.profiles;
aea1e4
     profiles.clear();
aea1e4
@@ -638,7 +633,6 @@ bool ModulePackageContainer::isChanged()
aea1e4
 void ModulePackageContainer::install(const std::string &name, const std::string &stream,
aea1e4
     const std::string &profile)
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     for (const auto &iter : pImpl->modules) {
aea1e4
         auto modulePackage = iter.second.get();
aea1e4
         if (modulePackage->getName() == name && modulePackage->getStream() == stream) {
aea1e4
@@ -656,7 +650,6 @@ void ModulePackageContainer::install(const ModulePackage * module, const std::st
aea1e4
 void ModulePackageContainer::uninstall(const std::string &name, const std::string &stream,
aea1e4
     const std::string &profile)
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     for (const auto &iter : pImpl->modules) {
aea1e4
         auto modulePackage = iter.second.get();
aea1e4
         if (modulePackage->getName() == name && modulePackage->getStream() == stream) {
aea1e4
@@ -744,7 +737,6 @@ ModulePackageContainer::query(Nsvcap& moduleNevra)
aea1e4
 std::vector<ModulePackage *>
aea1e4
 ModulePackageContainer::query(std::string subject)
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     // Alternatively a search using module provides could be performed
aea1e4
     std::vector<ModulePackage *> result;
aea1e4
     Query query(pImpl->moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
aea1e4
@@ -765,7 +757,6 @@ std::vector<ModulePackage *>
aea1e4
 ModulePackageContainer::query(std::string name, std::string stream, std::string version,
aea1e4
     std::string context, std::string arch)
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     // Alternatively a search using module provides could be performed
aea1e4
     std::vector<ModulePackage *> result;
aea1e4
     Query query(pImpl->moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
aea1e4
@@ -847,7 +838,6 @@ ModulePackageContainer::getModuleState(const std::string& name)
aea1e4
 
aea1e4
 std::set<std::string> ModulePackageContainer::getInstalledPkgNames()
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     auto moduleNames = pImpl->persistor->getAllModuleNames();
aea1e4
     std::set<std::string> pkgNames;
aea1e4
     for (auto & moduleName: moduleNames) {
aea1e4
@@ -1029,7 +1019,6 @@ std::vector<std::vector<std::vector<ModulePackage *>>>
aea1e4
 ModulePackageContainer::getLatestModulesPerRepo(ModuleState moduleFilter,
aea1e4
     std::vector<ModulePackage *> modulePackages)
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     if (modulePackages.empty()) {
aea1e4
         return {};
aea1e4
     }
aea1e4
@@ -1113,7 +1102,6 @@ ModulePackageContainer::getLatestModulesPerRepo(ModuleState moduleFilter,
aea1e4
 std::pair<std::vector<std::vector<std::string>>, ModulePackageContainer::ModuleErrorType>
aea1e4
 ModulePackageContainer::resolveActiveModulePackages(bool debugSolver)
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     dnf_sack_reset_excludes(pImpl->moduleSack);
aea1e4
     std::vector<ModulePackage *> packages;
aea1e4
 
aea1e4
@@ -1164,7 +1152,6 @@ bool ModulePackageContainer::isModuleActive(const ModulePackage * modulePackage)
aea1e4
 
aea1e4
 std::vector<ModulePackage *> ModulePackageContainer::getModulePackages()
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     std::vector<ModulePackage *> values;
aea1e4
     const auto & modules = pImpl->modules;
aea1e4
     std::transform(
aea1e4
@@ -1186,56 +1173,47 @@ void ModulePackageContainer::rollback()
aea1e4
 
aea1e4
 std::map<std::string, std::string> ModulePackageContainer::getEnabledStreams()
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     return pImpl->persistor->getEnabledStreams();
aea1e4
 }
aea1e4
 
aea1e4
 std::vector<std::string> ModulePackageContainer::getDisabledModules()
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     return pImpl->persistor->getDisabledModules();
aea1e4
 }
aea1e4
 
aea1e4
 std::map<std::string, std::string> ModulePackageContainer::getDisabledStreams()
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     return pImpl->persistor->getDisabledStreams();
aea1e4
 }
aea1e4
 
aea1e4
 std::vector<std::string> ModulePackageContainer::getResetModules()
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     return pImpl->persistor->getResetModules();
aea1e4
 }
aea1e4
 
aea1e4
 std::map<std::string, std::string> ModulePackageContainer::getResetStreams()
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     return pImpl->persistor->getResetStreams();
aea1e4
 }
aea1e4
 
aea1e4
 std::map<std::string, std::pair<std::string, std::string>>
aea1e4
 ModulePackageContainer::getSwitchedStreams()
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     return pImpl->persistor->getSwitchedStreams();
aea1e4
 }
aea1e4
 
aea1e4
 std::map<std::string, std::vector<std::string>> ModulePackageContainer::getInstalledProfiles()
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     return pImpl->persistor->getInstalledProfiles();
aea1e4
 }
aea1e4
 
aea1e4
 std::vector<std::string> ModulePackageContainer::getInstalledProfiles(std::string moduleName)
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     return pImpl->persistor->getProfiles(moduleName);
aea1e4
 }
aea1e4
 
aea1e4
 std::map<std::string, std::vector<std::string>> ModulePackageContainer::getRemovedProfiles()
aea1e4
 {
aea1e4
-    pImpl->addVersion2Modules();
aea1e4
     return pImpl->persistor->getRemovedProfiles();
aea1e4
 }
aea1e4
 const std::string &
aea1e4
@@ -1641,7 +1619,7 @@ ModulePackageContainer::Impl::ModulePersistor::getRemovedProfiles()
aea1e4
 void ModulePackageContainer::loadFailSafeData()
aea1e4
 {
aea1e4
     auto persistor = pImpl->persistor->configs;
aea1e4
-
aea1e4
+    
aea1e4
     std::map<std::string, std::pair<std::string, bool>> enabledStreams;
aea1e4
     for (auto & nameConfig: persistor) {
aea1e4
         if (nameConfig.second.second.state == ModuleState::ENABLED) {
aea1e4
-- 
aea1e4
2.31.1
aea1e4