Skip to content

Commit

Permalink
No M (#3137)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoinePrv authored Jan 18, 2024
1 parent a29f500 commit 0324bd7
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 103 deletions.
4 changes: 2 additions & 2 deletions libmamba/include/mamba/core/pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace mamba
class ChannelContext;
class Context;
class PrefixData;
class MSubdirData;
class SubdirData;

namespace fs
{
Expand Down Expand Up @@ -146,7 +146,7 @@ namespace mamba
};

// TODO machinery functions in separate files
auto load_subdir_in_pool(const Context& ctx, MPool& pool, const MSubdirData& subdir)
auto load_subdir_in_pool(const Context& ctx, MPool& pool, const SubdirData& subdir)
-> expected_t<solver::libsolv::RepoInfo>;

auto load_installed_packages_in_pool(const Context& ctx, MPool& pool, const PrefixData& prefix)
Expand Down
32 changes: 16 additions & 16 deletions libmamba/include/mamba/core/subdirdata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace mamba
class ChannelContext;
class DownloadMonitor;

class MSubdirMetadata
class SubdirMetadata
{
public:

Expand All @@ -41,7 +41,7 @@ namespace mamba
std::string cache_control;
};

using expected_subdir_metadata = tl::expected<MSubdirMetadata, mamba_error>;
using expected_subdir_metadata = tl::expected<SubdirMetadata, mamba_error>;

static expected_subdir_metadata read(const fs::u8path& file);
void write(const fs::u8path& file);
Expand Down Expand Up @@ -87,20 +87,20 @@ namespace mamba
friend void to_json(nlohmann::json& j, const CheckedAt& ca);
friend void from_json(const nlohmann::json& j, CheckedAt& ca);

friend void to_json(nlohmann::json& j, const MSubdirMetadata& data);
friend void from_json(const nlohmann::json& j, MSubdirMetadata& data);
friend void to_json(nlohmann::json& j, const SubdirMetadata& data);
friend void from_json(const nlohmann::json& j, SubdirMetadata& data);
};

/**
* Represents a channel subdirectory (i.e. a platform)
* packages index. Handles downloading of the index
* from the server and cache generation as well.
*/
class MSubdirData
class SubdirData
{
public:

static expected_t<MSubdirData> create(
static expected_t<SubdirData> create(
Context& ctx,
ChannelContext& channel_context,
const specs::Channel& channel,
Expand All @@ -110,21 +110,21 @@ namespace mamba
const std::string& repodata_fn = "repodata.json"
);

~MSubdirData() = default;
~SubdirData() = default;

MSubdirData(const MSubdirData&) = delete;
MSubdirData& operator=(const MSubdirData&) = delete;
SubdirData(const SubdirData&) = delete;
SubdirData& operator=(const SubdirData&) = delete;

MSubdirData(MSubdirData&&) = default;
MSubdirData& operator=(MSubdirData&&) = default;
SubdirData(SubdirData&&) = default;
SubdirData& operator=(SubdirData&&) = default;

bool is_noarch() const;
bool is_loaded() const;
void clear_cache();

const std::string& name() const;

const MSubdirMetadata& metadata() const;
const SubdirMetadata& metadata() const;

expected_t<fs::u8path> valid_solv_cache() const;
fs::u8path writable_solv_cache() const;
Expand All @@ -134,15 +134,15 @@ namespace mamba
expected_t<std::string> cache_path() const;

static expected_t<void> download_indexes(
std::vector<MSubdirData>& subdirs,
std::vector<SubdirData>& subdirs,
const Context& context,
DownloadMonitor* check_monitor = nullptr,
DownloadMonitor* download_monitor = nullptr
);

private:

MSubdirData(
SubdirData(
Context& ctx,
ChannelContext& channel_context,
const specs::Channel& channel,
Expand All @@ -161,7 +161,7 @@ namespace mamba
DownloadRequest build_index_request();

expected_t<void> use_existing_cache();
expected_t<void> finalize_transfer(MSubdirMetadata::HttpMetadata http_data);
expected_t<void> finalize_transfer(SubdirMetadata::HttpMetadata http_data);
void refresh_last_write_time(const fs::u8path& json_file, const fs::u8path& solv_file);

bool m_loaded = false;
Expand All @@ -178,7 +178,7 @@ namespace mamba
std::string m_solv_fn;
bool m_is_noarch;

MSubdirMetadata m_metadata;
SubdirMetadata m_metadata;
std::unique_ptr<TemporaryFile> m_temp_file;
const Context* p_context;
};
Expand Down
10 changes: 5 additions & 5 deletions libmamba/src/api/channel_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace mamba
ChannelContext& channel_context,
const specs::Channel& channel,
MultiPackageCache& package_caches,
std::vector<MSubdirData>& subdirs,
std::vector<SubdirData>& subdirs,
std::vector<mamba_error>& error_list,
std::vector<solver::libsolv::Priorities>& priorities,
int& max_prio,
Expand All @@ -57,7 +57,7 @@ namespace mamba
{
for (const auto& platform : channel.platforms())
{
auto sdires = MSubdirData::create(
auto sdires = SubdirData::create(
ctx,
channel_context,
channel,
Expand Down Expand Up @@ -96,7 +96,7 @@ namespace mamba
{
int RETRY_SUBDIR_FETCH = 1 << 0;

std::vector<MSubdirData> subdirs;
std::vector<SubdirData> subdirs;

std::vector<solver::libsolv::Priorities> priorities;
int max_prio = static_cast<int>(ctx.channels.size());
Expand Down Expand Up @@ -151,11 +151,11 @@ namespace mamba
{
SubdirDataMonitor check_monitor({ true, true });
SubdirDataMonitor index_monitor;
download_res = MSubdirData::download_indexes(subdirs, ctx, &check_monitor, &index_monitor);
download_res = SubdirData::download_indexes(subdirs, ctx, &check_monitor, &index_monitor);
}
else
{
download_res = MSubdirData::download_indexes(subdirs, ctx);
download_res = SubdirData::download_indexes(subdirs, ctx);
}

if (!download_res)
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 @@ -457,7 +457,7 @@ namespace mamba
}

// TODO machinery functions in separate files
auto load_subdir_in_pool(const Context& ctx, MPool& pool, const MSubdirData& subdir)
auto load_subdir_in_pool(const Context& ctx, MPool& pool, const SubdirData& subdir)
-> expected_t<solver::libsolv::RepoInfo>
{
const auto expected_cache_origin = solver::libsolv::RepodataOrigin{
Expand Down
Loading

0 comments on commit 0324bd7

Please sign in to comment.