From 4d125c27a67fc39b2b2f1db1eb54e098f2738c21 Mon Sep 17 00:00:00 2001 From: Andre Detsch Date: Mon, 26 Aug 2024 17:59:11 -0300 Subject: [PATCH] api: Remove unused parameter from getAvailableTargets getAvailableTargets is always called with `just_latest = false`. Remove the parameter and set the behavior to always return all available targets from the allowed_targets list. Signed-off-by: Andre Detsch --- src/api.cc | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/api.cc b/src/api.cc index d3a326d0..21e51be8 100644 --- a/src/api.cc +++ b/src/api.cc @@ -366,7 +366,7 @@ static void parseUpdateContent(const boost::filesystem::path& apps_dir, std::set static std::vector getAvailableTargets(const PackageConfig& pconfig, const std::vector& allowed_targets, - const UpdateSrc& src, bool just_latest = true) { + const UpdateSrc& src) { if (allowed_targets.empty()) { LOG_ERROR << "No targets are available for a given device; check a hardware ID and/or a tag"; return std::vector{}; @@ -383,8 +383,7 @@ static std::vector getAvailableTargets(const PackageConfig& pcon const OSTree::Repo repo{src.OstreeRepoDir.string()}; Uptane::Target found_target(Uptane::Target::Unknown()); - const std::string search_msg{just_latest ? "a target" : "all targets"}; - LOG_INFO << "Searching for " << search_msg << " starting from " << allowed_targets.begin()->filename() + LOG_INFO << "Searching for all targets starting from " << allowed_targets.begin()->filename() << " that match content provided in the source directory\n" << "\t pacman type: \t" << pconfig.type << "\n\t apps dir: \t" << src.AppsDir << "\n\t ostree dir: \t" << src.OstreeRepoDir; @@ -398,10 +397,7 @@ static std::vector getAvailableTargets(const PackageConfig& pcon custom_data[LocalSrcDirKey]["ostree"] = src.OstreeRepoDir.string(); found_targets.emplace_back(Target::updateCustom(t, custom_data)); LOG_INFO << "\t" << t.filename() << " - all target components have been found"; - if (!just_latest) { - continue; - } - break; + continue; } OfflineUpdateAppsShortlistType offline_app_shortlist_type; @@ -414,10 +410,7 @@ static std::vector getAvailableTargets(const PackageConfig& pcon custom_data.removeMember("docker_compose_apps"); found_targets.emplace_back(Target::updateCustom(t, custom_data)); LOG_INFO << "\t" << t.filename() << " - all target components have been found"; - if (!just_latest) { - continue; - } - break; + continue; } const ComposeAppManager::AppsContainer required_apps{ @@ -458,9 +451,6 @@ static std::vector getAvailableTargets(const PackageConfig& pcon custom_data[LocalSrcDirKey]["apps"] = src.AppsDir.string(); found_targets.emplace_back(Target::updateCustom(t, custom_data)); LOG_INFO << "\t" << t.filename() << " - all target components have been found"; - if (just_latest) { - break; - } } return found_targets; } @@ -572,8 +562,7 @@ CheckInResult AkliteClient::CheckInLocal(const LocalUpdateSource* local_update_s .AppsDir = local_update_source->app_store, }; std::vector available_targets = - getAvailableTargets(client_->config.pacman, fromTufTargets(matchingTargets), src, - false /* get all available targets, not just latest */); + getAvailableTargets(client_->config.pacman, fromTufTargets(matchingTargets), src); if (available_targets.empty()) { err_msg = "No update content found in ostree dir " + src.OstreeRepoDir.string() + " and app dir " + src.AppsDir.string(); @@ -619,8 +608,7 @@ CheckInResult AkliteClient::CheckInCurrent(const LocalUpdateSource* local_update .AppsDir = local_update_source->app_store, }; std::vector available_targets = - getAvailableTargets(client_->config.pacman, fromTufTargets(matchingTargets), src, - false /* get all available targets, not just latest */); + getAvailableTargets(client_->config.pacman, fromTufTargets(matchingTargets), src); if (available_targets.empty()) { err_msg = "No update content found in ostree dir " + src.OstreeRepoDir.string() + " and app dir " + src.AppsDir.string();