libdnf/SOURCES/0010-Revert-Call-addVersion2Modules-as-late-as-possible.patch
2021-11-24 04:21:37 +00:00

215 lines
8.1 KiB
Diff

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