Browse Source

Option to import the initial catalog content at any time

default_compile_flags
vector-of-bool 4 years ago
parent
commit
2df0b27af6
3 changed files with 11 additions and 0 deletions
  1. +4
    -0
      src/dds.main.cpp
  2. +6
    -0
      src/dds/catalog/catalog.cpp
  3. +1
    -0
      src/dds/catalog/catalog.hpp

+ 4
- 0
src/dds.main.cpp View File

catalog_path_flag cat_path{cmd}; catalog_path_flag cat_path{cmd};


args::Flag import_stdin{cmd, "stdin", "Import JSON from stdin", {"stdin"}}; args::Flag import_stdin{cmd, "stdin", "Import JSON from stdin", {"stdin"}};
args::Flag init{cmd, "initial", "Re-import the initial catalog contents", {"initial"}};
args::ValueFlagList<std::string> args::ValueFlagList<std::string>
json_paths{cmd, json_paths{cmd,
"json", "json",


int run() { int run() {
auto cat = cat_path.open(); auto cat = cat_path.open();
if (init.Get()) {
cat.import_initial();
}
for (const auto& json_fpath : json_paths.Get()) { for (const auto& json_fpath : json_paths.Get()) {
cat.import_json_file(json_fpath); cat.import_json_file(json_fpath);
} }

+ 6
- 0
src/dds/catalog/catalog.cpp View File

store(pkg); store(pkg);
} }
} }

void catalog::import_initial() {
sqlite3::transaction_guard tr{_db};
spdlog::info("Restoring built-in initial catalog contents");
store_init_packages(_db, _stmt_cache);
}

+ 1
- 0
src/dds/catalog/catalog.hpp View File

std::vector<package_id> by_name(std::string_view sv) const noexcept; std::vector<package_id> by_name(std::string_view sv) const noexcept;
std::vector<dependency> dependencies_of(const package_id& pkg) const noexcept; std::vector<dependency> dependencies_of(const package_id& pkg) const noexcept;


void import_initial();
void import_json_str(std::string_view json_str); void import_json_str(std::string_view json_str);
void import_json_file(path_ref json_path) { void import_json_file(path_ref json_path) {
auto content = dds::slurp_file(json_path); auto content = dds::slurp_file(json_path);

Loading…
Cancel
Save