Skip to content

Commit

Permalink
Rename PackageInfo::fn > filename
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoinePrv committed Jan 5, 2024
1 parent 878840c commit 259b013
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion libmamba/include/mamba/core/package_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace mamba
std::string channel = {};
std::string url = {};
std::string subdir = {};
std::string fn = {};
std::string filename = {};
std::string license = {};
std::size_t size = 0;
std::size_t timestamp = 0;
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/api/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ namespace mamba
p.subdir = ms.channel()->platform_filters().front();
}
}
p.fn = ms.filename();
p.filename = ms.filename();

if (hash != std::string::npos)
{
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/core/env_lockfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace mamba

package.info.url = package_node["url"].as<std::string>();
const auto spec = specs::MatchSpec::parse(package.info.url);
package.info.fn = spec.filename();
package.info.filename = spec.filename();
package.info.build_string = spec.build_string().str();
if (spec.channel().has_value())
{
Expand Down
14 changes: 7 additions & 7 deletions libmamba/src/core/package_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ namespace mamba
return m_valid_tarballs[pkg];
}

assert(!s.fn.empty());
const auto pkg_name = specs::strip_archive_extension(s.fn);
assert(!s.filename.empty());
const auto pkg_name = specs::strip_archive_extension(s.filename);
LOG_DEBUG << "Verify cache '" << m_path.string() << "' for package tarball '" << pkg_name
<< "'";

bool valid = false;
if (fs::exists(m_path / s.fn))
if (fs::exists(m_path / s.filename))
{
fs::u8path tarball_path = m_path / s.fn;
fs::u8path tarball_path = m_path / s.filename;
// validate that this tarball has the right size and MD5 sum
// we handle the case where s.size == 0 (explicit packages) or md5 is unknown
valid = s.size == 0 || validation::file_size(tarball_path, s.size);
Expand Down Expand Up @@ -201,7 +201,7 @@ namespace mamba
return m_valid_extracted_dir[pkg];
}

auto pkg_name = specs::strip_archive_extension(s.fn);
auto pkg_name = specs::strip_archive_extension(s.filename);
fs::u8path extracted_dir = m_path / pkg_name;
LOG_DEBUG << "Verify cache '" << m_path.string() << "' for package extracted directory '"
<< pkg_name << "'";
Expand Down Expand Up @@ -440,7 +440,7 @@ namespace mamba
}
else
{
LOG_ERROR << "Cannot find tarball cache for '" << s.fn << "'";
LOG_ERROR << "Cannot find tarball cache for '" << s.filename << "'";
throw std::runtime_error("Package cache error.");
}
}
Expand Down Expand Up @@ -469,7 +469,7 @@ namespace mamba
}
else
{
LOG_ERROR << "Cannot find a valid extracted directory cache for '" << s.fn << "'";
LOG_ERROR << "Cannot find a valid extracted directory cache for '" << s.filename << "'";
throw std::runtime_error("Package cache error.");
}
}
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/core/package_fetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ namespace mamba

const std::string& PackageFetcher::filename() const
{
return m_package_info.fn;
return m_package_info.filename;
}

const std::string& PackageFetcher::url() const
Expand Down
12 changes: 6 additions & 6 deletions libmamba/src/core/package_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ namespace mamba

auto PackageInfo::str() const -> std::string
{
if (!fn.empty())
if (!filename.empty())
{
return std::string(specs::strip_archive_extension(fn));
return std::string(specs::strip_archive_extension(filename));
}
return fmt::format("{}-{}-{}", name, version, build_string);
}
Expand Down Expand Up @@ -172,7 +172,7 @@ namespace mamba
}
if (field_name == "fn" || field_name == "filename")
{
return invoke_field_string(*this, &PackageInfo::fn);
return invoke_field_string(*this, &PackageInfo::filename);
}
if (field_name == "license")
{
Expand Down Expand Up @@ -202,7 +202,7 @@ namespace mamba
p.channel,
p.url,
p.subdir,
p.fn,
p.filename,
p.license,
p.size,
p.timestamp,
Expand Down Expand Up @@ -234,7 +234,7 @@ namespace mamba
j["channel"] = pkg.channel;
j["url"] = pkg.url;
j["subdir"] = pkg.subdir;
j["fn"] = pkg.fn;
j["fn"] = pkg.filename;
j["size"] = pkg.size;
j["timestamp"] = pkg.timestamp;
j["build"] = pkg.build_string;
Expand Down Expand Up @@ -280,7 +280,7 @@ namespace mamba
pkg.channel = j.value("channel", "");
pkg.url = j.value("url", "");
pkg.subdir = j.value("subdir", "");
pkg.fn = j.value("fn", "");
pkg.filename = j.value("fn", "");
pkg.size = j.value("size", std::size_t(0));
pkg.timestamp = j.value("timestamp", std::size_t(0));
if (std::string build = j.value("build", "<UNKNOWN>"); build != "<UNKNOWN>")
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/core/pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ namespace mamba
out.channel = s.channel();
out.url = s.url();
out.subdir = s.subdir();
out.fn = s.file_name();
out.filename = s.file_name();
out.license = s.license();
out.size = s.size();
out.timestamp = s.timestamp();
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/core/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ namespace mamba
fmt::print(out, " {:<15} {} kB\n", "Size", pkg.size / 1000);
fmt::print(out, fmtstring, "License", pkg.license);
fmt::print(out, fmtstring, "Subdir", pkg.subdir);
fmt::print(out, fmtstring, "File Name", pkg.fn);
fmt::print(out, fmtstring, "File Name", pkg.filename);

using CondaURL = typename specs::CondaURL;
auto url = CondaURL::parse(pkg.url);
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/core/repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace mamba
solv.set_channel(pkg.channel);
solv.set_url(pkg.url);
solv.set_subdir(pkg.subdir);
solv.set_file_name(pkg.fn);
solv.set_file_name(pkg.filename);
solv.set_license(pkg.license);
solv.set_size(pkg.size);
// TODO conda timestamp are not Unix timestamp.
Expand Down
8 changes: 4 additions & 4 deletions libmamba/src/core/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ namespace mamba
p.subdir = ms.channel()->platform_filters().front();
}
}
p.fn = ms.filename();
p.filename = ms.filename();
p.md5 = ms.md5();
p.sha256 = ms.sha256();
}
Expand Down Expand Up @@ -768,7 +768,7 @@ namespace mamba
m_solution.actions,
[&](const auto& pkg)
{
to_remove_structured.emplace_back(pkg.channel, pkg.fn); //
to_remove_structured.emplace_back(pkg.channel, pkg.filename); //
}
);

Expand All @@ -778,7 +778,7 @@ namespace mamba
m_solution.actions,
[&](const auto& pkg)
{
to_install_structured.emplace_back(pkg.channel, pkg.fn, nl::json(pkg).dump(4)); //
to_install_structured.emplace_back(pkg.channel, pkg.filename, nl::json(pkg).dump(4)); //
}
);

Expand Down Expand Up @@ -1247,7 +1247,7 @@ namespace mamba
{
if (str == "explicit_specs")
{
chan_name = s.fn;
chan_name = s.filename;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/core/virtual_packages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ namespace mamba
res.channel = "@";
res.subdir = subdir;
res.md5 = "12345678901234567890123456789012";
res.fn = name;
res.filename = name;
return res;
}

Expand Down
2 changes: 1 addition & 1 deletion libmamba/tests/src/core/test_virtual_packages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace mamba
CHECK_EQ(pkg.channel, "@");
CHECK_EQ(pkg.subdir, context.platform);
CHECK_EQ(pkg.md5, "12345678901234567890123456789012");
CHECK_EQ(pkg.fn, pkg.name);
CHECK_EQ(pkg.filename, pkg.name);
}

TEST_CASE("dist_packages")
Expand Down
2 changes: 1 addition & 1 deletion libmambapy/src/libmambapy/bindings/legacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ bind_submodule_impl(pybind11::module_ m)
.def_readwrite("channel", &PackageInfo::channel)
.def_readwrite("url", &PackageInfo::url)
.def_readwrite("subdir", &PackageInfo::subdir)
.def_readwrite("fn", &PackageInfo::fn)
.def_readwrite("fn", &PackageInfo::filename)
.def_readwrite("license", &PackageInfo::license)
.def_readwrite("size", &PackageInfo::size)
.def_readwrite("timestamp", &PackageInfo::timestamp)
Expand Down
14 changes: 7 additions & 7 deletions micromamba/src/constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ construct(Configuration& config, const fs::u8path& prefix, bool extract_conda_pk

for (const auto& pkg_info : package_details)
{
fs::u8path entry = pkgs_dir / pkg_info.fn;
LOG_TRACE << "Extracting " << pkg_info.fn << std::endl;
std::cout << "Extracting " << pkg_info.fn << std::endl;
fs::u8path entry = pkgs_dir / pkg_info.filename;
LOG_TRACE << "Extracting " << pkg_info.filename << std::endl;
std::cout << "Extracting " << pkg_info.filename << std::endl;

fs::u8path base_path = extract(entry, ExtractOptions::from_context(config.context()));

fs::u8path repodata_record_path = base_path / "info" / "repodata_record.json";
fs::u8path index_path = base_path / "info" / "index.json";

std::string channel_url;
if (pkg_info.url.size() > pkg_info.fn.size())
if (pkg_info.url.size() > pkg_info.filename.size())
{
channel_url = pkg_info.url.substr(0, pkg_info.url.size() - pkg_info.fn.size());
channel_url = pkg_info.url.substr(0, pkg_info.url.size() - pkg_info.filename.size());
}
std::string repodata_cache_name = util::concat(cache_name_from_url(channel_url), ".json");
fs::u8path repodata_location = pkgs_dir / "cache" / repodata_cache_name;
Expand All @@ -133,7 +133,7 @@ construct(Configuration& config, const fs::u8path& prefix, bool extract_conda_pk
repodatas[repodata_cache_name] = j;
}
auto& j = repodatas[repodata_cache_name];
repodata_record = find_package(j, pkg_info.fn);
repodata_record = find_package(j, pkg_info.filename);
}

nlohmann::json index;
Expand Down Expand Up @@ -162,7 +162,7 @@ construct(Configuration& config, const fs::u8path& prefix, bool extract_conda_pk
}
}

repodata_record["fn"] = pkg_info.fn;
repodata_record["fn"] = pkg_info.filename;
repodata_record["url"] = pkg_info.url;
repodata_record["channel"] = pkg_info.channel;

Expand Down

0 comments on commit 259b013

Please sign in to comment.