|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void repository::_init_repo_dir(path_ref dirpath) noexcept { |
|
|
void repository::_init_repo_dir(path_ref dirpath) noexcept { |
|
|
fs::create_directories(dirpath / "dist"); |
|
|
|
|
|
|
|
|
fs::create_directories(dirpath); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
fs::path repository::default_local_path() noexcept { return dds_data_dir() / "repo"; } |
|
|
fs::path repository::default_local_path() noexcept { return dds_data_dir() / "repo"; } |
|
|
|
|
|
|
|
|
repository repository::open_for_directory(path_ref dirpath) { |
|
|
repository repository::open_for_directory(path_ref dirpath) { |
|
|
auto dist_dir = dirpath / "dist"; |
|
|
|
|
|
|
|
|
auto dist_dir = dirpath; |
|
|
auto entries = fs::directory_iterator(dist_dir) | to_vector; |
|
|
auto entries = fs::directory_iterator(dist_dir) | to_vector; |
|
|
return {dirpath}; |
|
|
return {dirpath}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void repository::add_sdist(const sdist& sd, if_exists ife_action) { |
|
|
void repository::add_sdist(const sdist& sd, if_exists ife_action) { |
|
|
auto sd_dest |
|
|
auto sd_dest |
|
|
= _root / "dist" / fmt::format("{}_{}", sd.manifest.name, sd.manifest.version.to_string()); |
|
|
|
|
|
|
|
|
= _root / fmt::format("{}_{}", sd.manifest.name, sd.manifest.version.to_string()); |
|
|
if (fs::exists(sd_dest)) { |
|
|
if (fs::exists(sd_dest)) { |
|
|
auto msg = fmt::format("Source distribution '{}' is already available in the local repo", |
|
|
auto msg = fmt::format("Source distribution '{}' is already available in the local repo", |
|
|
sd.path.string()); |
|
|
sd.path.string()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return |
|
|
return |
|
|
// Get the top-level `name-version` dirs |
|
|
// Get the top-level `name-version` dirs |
|
|
fs::directory_iterator(_dist_dir()) // |
|
|
|
|
|
|
|
|
fs::directory_iterator(_root) // |
|
|
// // Convert each dir into an `sdist` object |
|
|
// // Convert each dir into an `sdist` object |
|
|
| transform(try_read_sdist) // |
|
|
| transform(try_read_sdist) // |
|
|
// // Drop items that failed to load |
|
|
// // Drop items that failed to load |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
std::optional<sdist> repository::get_sdist(std::string_view name, std::string_view version) const { |
|
|
std::optional<sdist> repository::get_sdist(std::string_view name, std::string_view version) const { |
|
|
auto expect_path = _dist_dir() / fmt::format("{}_{}", name, version); |
|
|
|
|
|
|
|
|
auto expect_path = _root / fmt::format("{}_{}", name, version); |
|
|
if (!fs::is_directory(expect_path)) { |
|
|
if (!fs::is_directory(expect_path)) { |
|
|
return std::nullopt; |
|
|
return std::nullopt; |
|
|
} |
|
|
} |