Skip to content

Commit

Permalink
Remove duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoinePrv committed Jan 18, 2024
1 parent f0decbd commit 8e1f689
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 46 deletions.
3 changes: 0 additions & 3 deletions libmamba/include/mamba/api/install.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ namespace mamba

yaml_file_contents read_yaml_file(fs::u8path yaml_file, const std::string platform);

std::tuple<std::vector<specs::PackageInfo>, std::vector<specs::MatchSpec>>
parse_urls_to_package_info(const std::vector<std::string>& urls);

inline void to_json(nlohmann::json&, const other_pkg_mgr_spec&)
{
}
Expand Down
40 changes: 0 additions & 40 deletions libmamba/src/api/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,46 +342,6 @@ namespace mamba
return result;
}

std::tuple<std::vector<specs::PackageInfo>, std::vector<specs::MatchSpec>>
parse_urls_to_package_info(const std::vector<std::string>& urls)
{
std::vector<specs::PackageInfo> pi_result;
std::vector<specs::MatchSpec> ms_result;
for (auto& u : urls)
{
if (util::strip(u).size() == 0)
{
continue;
}
std::size_t hash = u.find_first_of('#');
auto ms = specs::MatchSpec::parse(u.substr(0, hash));
specs::PackageInfo p(ms.name().str());
p.package_url = ms.url();
p.build_string = ms.build_string().str();
p.version = ms.version().str();
if (ms.channel().has_value())
{
p.channel = ms.channel()->location();
if (!ms.channel()->platform_filters().empty())
{
// There must be only one since we are expecting URLs
assert(ms.channel()->platform_filters().size() == 1);
p.subdir = ms.channel()->platform_filters().front();
}
}
p.filename = ms.filename();

if (hash != std::string::npos)
{
p.md5 = u.substr(hash + 1);
ms.set_md5(std::string(u.substr(hash + 1)));
}
pi_result.push_back(p);
ms_result.push_back(ms);
}
return std::make_tuple(pi_result, ms_result);
}

bool operator==(const other_pkg_mgr_spec& s1, const other_pkg_mgr_spec& s2)
{
return (s1.pkg_mgr == s2.pkg_mgr) && (s1.deps == s2.deps) && (s1.cwd == s2.cwd);
Expand Down
6 changes: 3 additions & 3 deletions micromamba/src/constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ construct(Configuration& config, const fs::u8path& prefix, bool extract_conda_pk
fs::u8path pkgs_dir = prefix / "pkgs";
fs::u8path urls_file = pkgs_dir / "urls";

auto [package_details, _] = detail::parse_urls_to_package_info(read_lines(urls_file));

for (const auto& pkg_info : package_details)
for (const auto& raw_url : read_lines(urls_file))
{
auto pkg_info = specs::PackageInfo::from_url(raw_url);

fs::u8path entry = pkgs_dir / pkg_info.filename;
LOG_TRACE << "Extracting " << pkg_info.filename << std::endl;
std::cout << "Extracting " << pkg_info.filename << std::endl;
Expand Down

0 comments on commit 8e1f689

Please sign in to comment.