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

repo: Drop unused fetch_metadata function #673

Merged
merged 1 commit into from
Jun 28, 2023
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
5 changes: 0 additions & 5 deletions include/libdnf5/repo/repo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,6 @@ class Repo {
friend class PackageDownloader;
friend class solv::Pool;

/// Downloads repository metadata from the origin or reads the local metadata cache if still valid.
/// @return true if fresh metadata were downloaded, false otherwise.
// @replaces libdnf:repo/Repo.hpp:method:Repo.load()
bool fetch_metadata();

void make_solv_repo();

void load_available_repo();
Expand Down
43 changes: 0 additions & 43 deletions libdnf5/repo/repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,49 +184,6 @@ bool Repo::is_local() const {
return false;
}

bool Repo::fetch_metadata() {
auto & logger = *base->get_logger();

if (downloader->get_metadata_path(RepoDownloader::MD_FILENAME_PRIMARY).empty()) {
// cache hasn't been loaded yet, try to load it
try {
read_metadata_cache();
} catch (std::runtime_error & e) {
// TODO(lukash) ideally we'd log something here, but we don't want it to look like an error
}
}

if (!downloader->get_metadata_path(RepoDownloader::MD_FILENAME_PRIMARY).empty()) {
// cache loaded
recompute_expired();
if (!expired || sync_strategy == SyncStrategy::ONLY_CACHE || sync_strategy == SyncStrategy::LAZY) {
logger.debug("Using cache for repo \"{}\"", config.get_id());
return false;
}

if (is_in_sync()) {
// the expired metadata still reflect the origin:
utimes(downloader->get_metadata_path(RepoDownloader::MD_FILENAME_PRIMARY).c_str(), nullptr);
RepoCache(base, config.get_cachedir()).remove_attribute(RepoCache::ATTRIBUTE_EXPIRED);
expired = false;
return true;
}
}
if (sync_strategy == SyncStrategy::ONLY_CACHE) {
throw RepoError(M_("Cache-only enabled but no cache for repository \"{}\""), config.get_id());
}

logger.debug("Downloading metadata for repo \"{}\"", config.get_id());
auto cache_dir = config.get_cachedir();
downloader->download_metadata(cache_dir);
RepoCache(base, config.get_cachedir()).remove_attribute(RepoCache::ATTRIBUTE_EXPIRED);
timestamp = -1;
read_metadata_cache();

expired = false;
return true;
}

void Repo::read_metadata_cache() {
downloader->reset_loaded();
downloader->load_local();
Expand Down