Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set POOL_FLAG_ADDFILEPROVIDESFILTERED only when not loading filelists #1741

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions libdnf5/repo/repo_sack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>.
#include "conf/config.h"
#include "repo_cache_private.hpp"
#include "repo_downloader.hpp"
#include "solv/pool.hpp"
#include "solv/solver.hpp"
#include "solv_repo.hpp"
#include "utils/auth.hpp"
Expand Down Expand Up @@ -71,6 +72,23 @@ constexpr const char * STORED_TRANSACTION_NAME = "@stored_transaction";
// TODO lukash: unused, remove?
//constexpr const char * MODULE_FAIL_SAFE_REPO_NAME = "@modulefailsafe";

void load_repos_common(libdnf5::BaseWeakPtr & base) {
auto optional_metadata = base->get_config().get_optional_metadata_types_option().get_value();
if (!optional_metadata.contains(libdnf5::METADATA_TYPE_FILELISTS)) {
// Configures the pool_addfileprovides_queue() method to only add files from primary.xml.
// This ensures the method works correctly even if filelist.xml metadata are not loaded.
// When searching for file provides outside of primary.xml this flag incurs a big performance
// hit because libsolv has to go through all the files for each file provide therefore don't
// set it if filelists are loaded.
set_rpm_pool_flag(base, POOL_FLAG_ADDFILEPROVIDESFILTERED, 1);
}

if (!base->are_repos_configured()) {
base->notify_repos_configured();
}
}


} // namespace

namespace libdnf5::repo {
Expand Down Expand Up @@ -598,9 +616,7 @@ void RepoSack::update_and_load_enabled_repos(bool load_system) {
void RepoSack::load_repos() {
auto & base = p_impl->base;

if (!base->are_repos_configured()) {
base->notify_repos_configured();
}
load_repos_common(base);

// create the system repository if it does not exist
base->get_repo_sack()->get_system_repo();
Expand All @@ -612,9 +628,7 @@ void RepoSack::load_repos() {
void RepoSack::load_repos(Repo::Type type) {
auto & base = p_impl->base;

if (!base->are_repos_configured()) {
base->notify_repos_configured();
}
load_repos_common(base);

libdnf_user_assert(
(type == libdnf5::repo::Repo::Type::AVAILABLE) || (type == libdnf5::repo::Repo::Type::SYSTEM),
Expand Down
11 changes: 6 additions & 5 deletions libdnf5/solv/pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ class Pool {
pool_set_flag(pool, POOL_FLAG_WHATPROVIDESWITHDISABLED, 1);
// Allow packages of the same name with different architectures to be installed in parallel
pool_set_flag(pool, POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS, 1);
// Configures the pool_addfileprovides_queue() method to only add files from primary.xml.
// This ensures the method works correctly even if filelist.xml metadata are not loaded.
// At the same time when filelist.xml are loaded libsolv is able to search them for required
// files if needed.
pool_set_flag(pool, POOL_FLAG_ADDFILEPROVIDESFILTERED, 1);
}

Pool(const Pool & pool) = delete;
Expand Down Expand Up @@ -259,6 +254,8 @@ class Pool {
}
}

int set_flag(int flag, int value) { return pool_set_flag(pool, flag, value); }

protected:
SolvMap considered; // owner of the considered map, `pool->considered` is only a raw pointer
::Pool * pool;
Expand Down Expand Up @@ -325,6 +322,10 @@ static inline solv::CompsPool & get_comps_pool(const libdnf5::BaseWeakPtr & base
return InternalBaseUser::get_comps_pool(base);
}

static inline int set_rpm_pool_flag(const libdnf5::BaseWeakPtr & base, int flag, int value) {
return InternalBaseUser::get_rpm_pool(base).set_flag(flag, value);
}

} // namespace libdnf5

#endif // LIBDNF5_SOLV_POOL_HPP
Loading