Browse Source

No `dist` subdir in repo. We'll get back to that...

default_compile_flags
vector-of-bool 5 years ago
parent
commit
0e9fa6f64b
2 changed files with 6 additions and 8 deletions
  1. +5
    -5
      src/dds/repo/repo.cpp
  2. +1
    -3
      src/dds/repo/repo.hpp

+ 5
- 5
src/dds/repo/repo.cpp View File

} }


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;
} }

+ 1
- 3
src/dds/repo/repo.hpp View File

static void _log_blocking(path_ref dir) noexcept; static void _log_blocking(path_ref dir) noexcept;
static void _init_repo_dir(path_ref dir) noexcept; static void _init_repo_dir(path_ref dir) noexcept;


fs::path _dist_dir() const noexcept { return _root / "dist"; }

public: public:
template <typename Func> template <typename Func>
static decltype(auto) with_repository(path_ref dirpath, repo_flags flags, Func&& fn) { static decltype(auto) with_repository(path_ref dirpath, repo_flags flags, Func&& fn) {
} }
} }


shared_file_mutex mut{dirpath / ".lock"};
shared_file_mutex mut{dirpath / ".dds-repo-lock"};
std::shared_lock shared_lk{mut, std::defer_lock}; std::shared_lock shared_lk{mut, std::defer_lock};
std::unique_lock excl_lk{mut, std::defer_lock}; std::unique_lock excl_lk{mut, std::defer_lock};



Loading…
Cancel
Save