mirror of https://github.com/mamba-org/mamba.git
Fixed zst check in MSubdirData (#2661)
This commit is contained in:
parent
3b6e10159f
commit
c46647a880
|
@ -61,7 +61,7 @@ namespace mamba
|
|||
void serialize_to_stream(std::ostream& out) const;
|
||||
void serialize_to_stream_tiny(std::ostream& out) const;
|
||||
|
||||
bool check_zst(const Channel* channel);
|
||||
bool check_zst(ChannelContext& channel_context, const Channel* channel);
|
||||
};
|
||||
|
||||
|
||||
|
@ -75,6 +75,7 @@ namespace mamba
|
|||
public:
|
||||
|
||||
static expected_t<MSubdirData> create(
|
||||
ChannelContext& channel_context,
|
||||
const Channel& channel,
|
||||
const std::string& platform,
|
||||
const std::string& url,
|
||||
|
@ -112,6 +113,7 @@ namespace mamba
|
|||
private:
|
||||
|
||||
MSubdirData(
|
||||
ChannelContext& channel_context,
|
||||
const Channel& channel,
|
||||
const std::string& platform,
|
||||
const std::string& url,
|
||||
|
@ -119,7 +121,7 @@ namespace mamba
|
|||
const std::string& repodata_fn = "repodata.json"
|
||||
);
|
||||
|
||||
bool load(MultiPackageCache& caches);
|
||||
bool load(MultiPackageCache& caches, ChannelContext& channel_context);
|
||||
void check_repodata_existence();
|
||||
void create_target();
|
||||
std::size_t get_cache_control_max_age(const std::string& val);
|
||||
|
|
|
@ -67,7 +67,14 @@ namespace mamba
|
|||
{
|
||||
for (auto& [platform, url] : channel->platform_urls(true))
|
||||
{
|
||||
auto sdires = MSubdirData::create(*channel, platform, url, package_caches, "repodata.json");
|
||||
auto sdires = MSubdirData::create(
|
||||
pool.channel_context(),
|
||||
*channel,
|
||||
platform,
|
||||
url,
|
||||
package_caches,
|
||||
"repodata.json"
|
||||
);
|
||||
if (!sdires.has_value())
|
||||
{
|
||||
error_list.push_back(std::move(sdires).error());
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace mamba
|
|||
out << j.dump();
|
||||
}
|
||||
|
||||
bool subdir_metadata::check_zst(const Channel* channel)
|
||||
bool subdir_metadata::check_zst(ChannelContext& channel_context, const Channel* channel)
|
||||
{
|
||||
if (has_zst.has_value())
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ namespace mamba
|
|||
|
||||
for (const auto& c : Context::instance().repodata_has_zst)
|
||||
{
|
||||
if (contains(c, channel->location()) && contains(c, channel->name()))
|
||||
if (channel_context.make_channel(c) == *channel)
|
||||
{
|
||||
has_zst = { true,
|
||||
std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()) };
|
||||
|
@ -295,6 +295,7 @@ namespace mamba
|
|||
}
|
||||
|
||||
expected_t<MSubdirData> MSubdirData::create(
|
||||
ChannelContext& channel_context,
|
||||
const Channel& channel,
|
||||
const std::string& platform,
|
||||
const std::string& url,
|
||||
|
@ -304,7 +305,7 @@ namespace mamba
|
|||
{
|
||||
try
|
||||
{
|
||||
return MSubdirData(channel, platform, url, caches, repodata_fn);
|
||||
return MSubdirData(channel_context, channel, platform, url, caches, repodata_fn);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
|
@ -320,6 +321,7 @@ namespace mamba
|
|||
}
|
||||
|
||||
MSubdirData::MSubdirData(
|
||||
ChannelContext& channel_context,
|
||||
const Channel& channel,
|
||||
const std::string& platform,
|
||||
const std::string& url,
|
||||
|
@ -338,7 +340,7 @@ namespace mamba
|
|||
{
|
||||
m_json_fn = cache_fn_url(m_repodata_url);
|
||||
m_solv_fn = m_json_fn.substr(0, m_json_fn.size() - 4) + "solv";
|
||||
load(caches);
|
||||
load(caches, channel_context);
|
||||
}
|
||||
|
||||
MSubdirData::MSubdirData(MSubdirData&& rhs)
|
||||
|
@ -485,7 +487,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
bool MSubdirData::load(MultiPackageCache& caches)
|
||||
bool MSubdirData::load(MultiPackageCache& caches, ChannelContext& channel_context)
|
||||
{
|
||||
auto now = fs::file_time_type::clock::now();
|
||||
|
||||
|
@ -601,7 +603,7 @@ namespace mamba
|
|||
bool has_value = m_metadata.has_zst.has_value();
|
||||
bool is_expired = m_metadata.has_zst.has_value()
|
||||
&& m_metadata.has_zst.value().has_expired();
|
||||
bool has_zst = m_metadata.check_zst(p_channel);
|
||||
bool has_zst = m_metadata.check_zst(channel_context, p_channel);
|
||||
if (!has_zst && (is_expired || !has_value))
|
||||
{
|
||||
m_check_targets.push_back(std::make_unique<DownloadTarget>(
|
||||
|
|
|
@ -314,7 +314,8 @@ namespace
|
|||
{
|
||||
for (auto& [platform, url] : chan->platform_urls(true))
|
||||
{
|
||||
auto sub_dir = expected_value_or_throw(MSubdirData::create(*chan, platform, url, cache)
|
||||
auto sub_dir = expected_value_or_throw(
|
||||
MSubdirData::create(pool.channel_context(), *chan, platform, url, cache)
|
||||
);
|
||||
dlist.add(sub_dir.target());
|
||||
sub_dirs.push_back(std::move(sub_dir));
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace mamba
|
|||
mamba::MultiDownloadTarget multi_dl;
|
||||
mamba::MultiPackageCache pkg_cache({ "/tmp/" });
|
||||
mamba::MSubdirData cf = mamba::MSubdirData::create(
|
||||
channel_context,
|
||||
c,
|
||||
"linux-64",
|
||||
"file:///nonexistent/repodata.json",
|
||||
|
@ -46,6 +47,7 @@ namespace mamba
|
|||
mamba::MultiDownloadTarget multi_dl;
|
||||
mamba::MultiPackageCache pkg_cache({ "/tmp/" });
|
||||
mamba::MSubdirData cf = mamba::MSubdirData::create(
|
||||
channel_context,
|
||||
c,
|
||||
"noarch",
|
||||
"file:///nonexistent/repodata.json",
|
||||
|
|
|
@ -462,7 +462,14 @@ PYBIND11_MODULE(bindings, m)
|
|||
MultiPackageCache& caches,
|
||||
const std::string& repodata_fn) -> MSubdirData
|
||||
{
|
||||
auto sres = MSubdirData::create(channel, platform, url, caches, repodata_fn);
|
||||
auto sres = MSubdirData::create(
|
||||
mambapy::singletons().channel_context,
|
||||
channel,
|
||||
platform,
|
||||
url,
|
||||
caches,
|
||||
repodata_fn
|
||||
);
|
||||
return extract(std::move(sres));
|
||||
}
|
||||
))
|
||||
|
|
Loading…
Reference in New Issue