mirror of https://github.com/mamba-org/mamba.git
Remove need to manually call SubdirData.load() (#1554)
This commit is contained in:
parent
3f067c575f
commit
3e4a839fc5
|
@ -31,12 +31,6 @@ namespace decompress
|
|||
|
||||
namespace mamba
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
// read the header that contains json like {"_mod": "...", ...}
|
||||
nlohmann::json read_mod_and_etag(const fs::path& file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a channel subdirectory (i.e. a platform)
|
||||
* packages index. Handles downloading of the index
|
||||
|
@ -54,8 +48,7 @@ namespace mamba
|
|||
// TODO return seconds as double
|
||||
fs::file_time_type::duration check_cache(const fs::path& cache_file,
|
||||
const fs::file_time_type::clock::time_point& ref);
|
||||
bool load();
|
||||
bool loaded();
|
||||
bool loaded() const;
|
||||
|
||||
bool forbid_cache();
|
||||
void clear_cache();
|
||||
|
@ -69,6 +62,7 @@ namespace mamba
|
|||
MRepo& create_repo(MPool& pool);
|
||||
|
||||
private:
|
||||
bool load();
|
||||
bool decompress();
|
||||
void create_target(nlohmann::json& mod_etag);
|
||||
std::size_t get_cache_control_max_age(const std::string& val);
|
||||
|
|
|
@ -56,7 +56,6 @@ namespace mamba
|
|||
{
|
||||
auto sdir = std::make_shared<MSubdirData>(*channel, platform, url, package_caches);
|
||||
|
||||
sdir->load();
|
||||
multi_dl.add(sdir->target());
|
||||
subdirs.push_back(sdir);
|
||||
if (ctx.channel_priority == ChannelPriority::kDisabled)
|
||||
|
|
|
@ -176,6 +176,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();
|
||||
}
|
||||
|
||||
fs::file_time_type::duration MSubdirData::check_cache(
|
||||
|
@ -194,7 +195,7 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
bool MSubdirData::loaded()
|
||||
bool MSubdirData::loaded() const
|
||||
{
|
||||
return m_loaded;
|
||||
}
|
||||
|
|
|
@ -503,6 +503,12 @@ namespace mamba
|
|||
EXPECT_FALSE(lexists("emptytestfile"));
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
// read the header that contains json like {"_mod": "...", ...}
|
||||
nlohmann::json read_mod_and_etag(const fs::path& file);
|
||||
}
|
||||
|
||||
TEST(subdirdata, parse_mod_etag)
|
||||
{
|
||||
fs::path cache_folder = fs::path("repodata_json_cache");
|
||||
|
|
|
@ -14,7 +14,6 @@ namespace mamba
|
|||
mamba::MultiDownloadTarget multi_dl;
|
||||
mamba::MultiPackageCache pkg_cache({ "/tmp/" });
|
||||
mamba::MSubdirData cf(c, "linux-64", "file:///nonexistent/repodata.json", pkg_cache);
|
||||
cf.load();
|
||||
multi_dl.add(cf.target());
|
||||
|
||||
// file:// url should not retry
|
||||
|
@ -30,7 +29,6 @@ namespace mamba
|
|||
mamba::MultiDownloadTarget multi_dl;
|
||||
mamba::MultiPackageCache pkg_cache({ "/tmp/" });
|
||||
mamba::MSubdirData cf(c, "noarch", "file:///nonexistent/repodata.json", pkg_cache);
|
||||
cf.load();
|
||||
multi_dl.add(cf.target());
|
||||
EXPECT_THROW(multi_dl.download(MAMBA_DOWNLOAD_FAILFAST), std::runtime_error);
|
||||
}
|
||||
|
|
|
@ -232,7 +232,6 @@ PYBIND11_MODULE(bindings, m)
|
|||
MultiPackageCache&,
|
||||
const std::string&>())
|
||||
.def("create_repo", &MSubdirData::create_repo, py::return_value_policy::reference)
|
||||
.def("load", &MSubdirData::load)
|
||||
.def("loaded", &MSubdirData::loaded)
|
||||
.def("cache_path", &MSubdirData::cache_path);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import libmambapy as api
|
|||
def load_channel(subdir_data, result_container):
|
||||
if not context.quiet:
|
||||
print("Getting ", subdir_data.channel.name, subdir_data.channel.platform)
|
||||
return result_container.append(subdir_data.load())
|
||||
return result_container.append(subdir_data.loaded())
|
||||
|
||||
|
||||
def get_index(
|
||||
|
@ -85,8 +85,6 @@ def get_index(
|
|||
channel, channel_platform, full_url, pkgs_dirs, repodata_fn
|
||||
)
|
||||
|
||||
sd.load()
|
||||
|
||||
index.append(
|
||||
(sd, {"platform": channel_platform, "url": url, "channel": channel})
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue