Skip to content

dnfdaemon: Configure separate cache directory #2185

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 9 additions & 2 deletions libdnf5/repo/repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,14 @@ bool Repo::clone_root_metadata() {

auto repo_cachedir = p_impl->config.get_cachedir();
auto base_cachedir = p_impl->config.get_basecachedir_option().get_value();
auto system_cachedir = p_impl->config.get_main_config().get_system_cachedir_option().get_value();

// return fast if the system_cachedir does not exist or is equivelent to base_cachedir
std::error_code ec;
if (!std::filesystem::exists(system_cachedir, ec) ||
std::filesystem::equivalent(base_cachedir, system_cachedir, ec)) {
return false;
}

auto base_path_pos = repo_cachedir.find(base_cachedir);
libdnf_assert(
Expand All @@ -529,8 +537,7 @@ bool Repo::clone_root_metadata() {
base_cachedir);

auto root_repo_cachedir = repo_cachedir;
root_repo_cachedir.replace(
base_path_pos, base_cachedir.size(), p_impl->config.get_main_config().get_system_cachedir_option().get_value());
root_repo_cachedir.replace(base_path_pos, base_cachedir.size(), system_cachedir);

auto root_repodata_cachedir = std::filesystem::path(root_repo_cachedir) / CACHE_METADATA_DIR;
try {
Expand Down
2 changes: 1 addition & 1 deletion libdnf5/repo/repo_sack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ void RepoSack::Impl::update_and_load_repos(libdnf5::repo::RepoQuery & repos, boo
send_to_sack_loader(repo);
} else {
// Try reusing the root cache
if (!root_cache_tried && !libdnf5::utils::am_i_root() && repo->clone_root_metadata()) {
if (!root_cache_tried && repo->clone_root_metadata()) {
root_cache_tried = true;
continue;
}
Expand Down