Skip to content

Commit

Permalink
Fix channel in PackageInfo (#3681)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hind-M authored Dec 12, 2024
1 parent 384ba63 commit a25cde7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libmamba/src/core/package_fetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ namespace mamba
{
caches.clear_query_cache(m_package_info);
// need to download this file
LOG_DEBUG << "Adding '" << name() << "' to download targets from '" << channel()
<< "/" << url_path() << "'";
LOG_DEBUG << "Adding '" << name() << "' to download targets from '"
<< hide_secrets(channel()) << "/" << url_path() << "'";
m_tarball_path = m_cache_path / filename();
m_needs_extract = true;
m_needs_download = true;
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/download/downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ namespace mamba::download
{
Error error;
error.message = std::string("Could not find mirrors for channel ")
+ p_initial_request->mirror_name;
+ hide_secrets(p_initial_request->mirror_name);
m_attempt_results.push_back(tl::unexpected(std::move(error)));
}
}
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/specs/package_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace mamba::specs
{
out.platform = url.platform_name();
url.clear_platform();
out.channel = util::rstrip(url.str(), '/');
out.channel = util::rstrip(url.str(specs::CondaURL::Credentials::Show), '/');

// Note that we use `rsplit...` instead of `split...`
// because the package name may contain '-'.
Expand Down
21 changes: 21 additions & 0 deletions libmamba/tests/src/specs/test_package_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,27 @@ namespace
REQUIRE(pkg.channel == "https://conda.anaconda.org/conda-forge");
}

SECTION("http://localhost:32826/t/1a5eb8d110994feaa53d0d9f8bf13bbb/get/proxy-channel/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2#d7c89558ba9fa0495403155b64376d81"
)
{
static constexpr std::string_view url = "http://localhost:32826/t/1a5eb8d110994feaa53d0d9f8bf13bbb/get/proxy-channel/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2#d7c89558ba9fa0495403155b64376d81";

auto pkg = PackageInfo::from_url(url).value();

REQUIRE(pkg.name == "_libgcc_mutex");
REQUIRE(pkg.version == "0.1");
REQUIRE(pkg.build_string == "conda_forge");
REQUIRE(pkg.filename == "_libgcc_mutex-0.1-conda_forge.tar.bz2");
REQUIRE(pkg.package_url == url.substr(0, url.rfind('#')));
REQUIRE(pkg.md5 == url.substr(url.rfind('#') + 1));
REQUIRE(pkg.platform == "linux-64");
// Make sure the token is not censored when setting the channel
REQUIRE(
pkg.channel
== "http://localhost:32826/t/1a5eb8d110994feaa53d0d9f8bf13bbb/get/proxy-channel"
);
}

SECTION("https://conda.anaconda.org/conda-forge/linux-64/pkg.conda")
{
static constexpr std::string_view url = "https://conda.anaconda.org/conda-forge/linux-64/pkg.conda";
Expand Down

0 comments on commit a25cde7

Please sign in to comment.