From b967f911ed5edb620a8a73b8c1bd65dd678686b9 Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Fri, 3 Jan 2025 16:50:13 +0100 Subject: [PATCH] Code review: renaming and restructuring --- .../include/mamba/core/package_fetcher.hpp | 2 +- libmamba/src/core/package_fetcher.cpp | 22 ++++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/libmamba/include/mamba/core/package_fetcher.hpp b/libmamba/include/mamba/core/package_fetcher.hpp index 4188f0347a..faaec08f2d 100644 --- a/libmamba/include/mamba/core/package_fetcher.hpp +++ b/libmamba/include/mamba/core/package_fetcher.hpp @@ -102,7 +102,7 @@ namespace mamba struct CheckSumParams; bool is_local_package() const; - bool use_explicit_url() const; + bool use_explicit_https_url() const; const std::string& filename() const; std::string channel() const; std::string url_path() const; diff --git a/libmamba/src/core/package_fetcher.cpp b/libmamba/src/core/package_fetcher.cpp index cdddcd875a..80f21d61fd 100644 --- a/libmamba/src/core/package_fetcher.cpp +++ b/libmamba/src/core/package_fetcher.cpp @@ -322,7 +322,7 @@ namespace mamba return util::starts_with(m_package_info.package_url, "file://"); } - bool PackageFetcher::use_explicit_url() const + bool PackageFetcher::use_explicit_https_url() const { // This excludes OCI case, which uses explicitly a "oci://" scheme, // but is resolved later to something starting with `oci_base_url` @@ -338,28 +338,24 @@ namespace mamba std::string PackageFetcher::channel() const { - if (!is_local_package() && !use_explicit_url()) - { - return m_package_info.channel; - } - // Use explicit url to fetch package and leave channel empty - else + if (is_local_package() || use_explicit_https_url()) { + // Use explicit url or local package path + // to fetch package, leaving the channel empty. return ""; } + return m_package_info.channel; } std::string PackageFetcher::url_path() const { - if (!is_local_package() && !use_explicit_url()) - { - return util::concat(m_package_info.platform, '/', m_package_info.filename); - } - // Use explicit url to fetch package - else + if (is_local_package() || use_explicit_https_url()) { + // Use explicit url or local package path + // to fetch package. return m_package_info.package_url; } + return util::concat(m_package_info.platform, '/', m_package_info.filename); } const std::string& PackageFetcher::url() const