From 7e3a249d546257092748f5f0bbfa3141adb8e5f9 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 93c99f6a..9424d278 100644 --- a/src/api.cc +++ b/src/api.cc @@ -369,7 +369,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{}; @@ -386,8 +386,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; @@ -401,10 +400,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; @@ -417,10 +413,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{ @@ -461,9 +454,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; } @@ -579,8 +569,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(); @@ -626,8 +615,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();