Pārlūkot izejas kodu

remote_repository -> pkg_remote, and some #include cleanup

default_compile_flags
vector-of-bool pirms 3 gadiem
vecāks
revīzija
63a8410ec2
8 mainītis faili ar 20 papildinājumiem un 28 dzēšanām
  1. +2
    -2
      src/dds/cli/cmd/build.cpp
  2. +3
    -3
      src/dds/cli/cmd/pkg_repo_add.cpp
  3. +1
    -1
      src/dds/cli/cmd/pkg_repo_update.cpp
  4. +0
    -2
      src/dds/cli/dispatch_main.cpp
  5. +1
    -0
      src/dds/pkg/db.cpp
  6. +3
    -5
      src/dds/pkg/db.hpp
  7. +5
    -5
      src/dds/pkg/remote.cpp
  8. +5
    -10
      src/dds/pkg/remote.hpp

+ 2
- 2
src/dds/cli/cmd/build.cpp Parādīt failu

@@ -5,7 +5,7 @@
#include <dds/build/builder.hpp>
#include <dds/error/errors.hpp>
#include <dds/pkg/db.hpp>
#include <dds/remote/remote.hpp>
#include <dds/pkg/remote.hpp>
#include <dds/toolchain/from_json.hpp>

using namespace dds;
@@ -16,7 +16,7 @@ int build(const options& opts) {
if (!opts.build.add_repos.empty()) {
auto cat = opts.open_catalog();
for (auto& str : opts.build.add_repos) {
auto repo = remote_repository::connect(str);
auto repo = pkg_remote::connect(str);
repo.store(cat.database());
}
}

+ 3
- 3
src/dds/cli/cmd/pkg_repo_add.cpp Parādīt failu

@@ -3,16 +3,16 @@
#include "./pkg_repo_err_handle.hpp"

#include <dds/pkg/db.hpp>
#include <dds/remote/remote.hpp>
#include <dds/pkg/remote.hpp>

namespace dds::cli::cmd {

static int _pkg_repo_add(const options& opts) {
auto cat = opts.open_catalog();
auto repo = remote_repository::connect(opts.pkg.repo.add.url);
auto repo = pkg_remote::connect(opts.pkg.repo.add.url);
repo.store(cat.database());
if (opts.pkg.repo.add.update) {
repo.update_catalog(cat.database());
repo.update_pkg_db(cat.database());
}
return 0;
}

+ 1
- 1
src/dds/cli/cmd/pkg_repo_update.cpp Parādīt failu

@@ -3,7 +3,7 @@
#include "./pkg_repo_err_handle.hpp"

#include <dds/pkg/db.hpp>
#include <dds/remote/remote.hpp>
#include <dds/pkg/remote.hpp>

namespace dds::cli::cmd {


+ 0
- 2
src/dds/cli/dispatch_main.cpp Parādīt failu

@@ -3,8 +3,6 @@
#include "./error_handler.hpp"
#include "./options.hpp"

#include <dds/pkg/db.hpp>
#include <dds/remote/remote.hpp>
#include <dds/util/paths.hpp>
#include <dds/util/result.hpp>


+ 1
- 0
src/dds/pkg/db.cpp Parādīt failu

@@ -12,6 +12,7 @@
#include <neo/sqlite3/exec.hpp>
#include <neo/sqlite3/iter_tuples.hpp>
#include <neo/sqlite3/single.hpp>
#include <neo/sqlite3/transaction.hpp>
#include <nlohmann/json.hpp>
#include <range/v3/range/conversion.hpp>
#include <range/v3/view/join.hpp>

+ 3
- 5
src/dds/pkg/db.hpp Parādīt failu

@@ -2,22 +2,20 @@

#include "./info.hpp"

#include <dds/deps.hpp>
#include <dds/pkg/id.hpp>
#include <dds/util/fs.hpp>
#include <dds/util/glob.hpp>

#include <neo/sqlite3/database.hpp>
#include <neo/sqlite3/statement.hpp>
#include <neo/sqlite3/statement_cache.hpp>
#include <neo/sqlite3/transaction.hpp>

#include <string>
#include <variant>
#include <vector>

namespace dds {

struct dependency;
struct pkg_id;

class pkg_db {
neo::sqlite3::database _db;
mutable neo::sqlite3::statement_cache _stmt_cache{_db};

src/dds/remote/remote.cpp → src/dds/pkg/remote.cpp Parādīt failu

@@ -59,7 +59,7 @@ struct remote_db {

} // namespace

remote_repository remote_repository::connect(std::string_view url_str) {
pkg_remote pkg_remote::connect(std::string_view url_str) {
DDS_E_SCOPE(e_url_string{std::string(url_str)});
const auto url = neo::url::parse(url_str);

@@ -70,7 +70,7 @@ remote_repository remote_repository::connect(std::string_view url_str) {
return {name, url};
}

void remote_repository::store(nsql::database_ref db) {
void pkg_remote::store(nsql::database_ref db) {
auto st = db.prepare(R"(
INSERT INTO dds_cat_remotes (name, gen_ident, remote_url)
VALUES (?, ?, ?)
@@ -80,7 +80,7 @@ void remote_repository::store(nsql::database_ref db) {
nsql::exec(st, _name, "[placeholder]", _base_url.to_string());
}

void remote_repository::update_catalog(nsql::database_ref db) {
void pkg_remote::update_pkg_db(nsql::database_ref db) {
dds_log(info, "Pulling repository contents for {} [{}]", _name, _base_url.to_string());

auto rdb = remote_db::download_and_open_for_base(_base_url);
@@ -174,8 +174,8 @@ void dds::update_all_remotes(nsql::database_ref db) {

for (const auto& [name, remote_url] : tups) {
DDS_E_SCOPE(e_url_string{remote_url});
remote_repository repo{name, neo::url::parse(remote_url)};
repo.update_catalog(db);
pkg_remote repo{name, neo::url::parse(remote_url)};
repo.update_pkg_db(db);
}

dds_log(info, "Recompacting database...");

src/dds/remote/remote.hpp → src/dds/pkg/remote.hpp Parādīt failu

@@ -1,31 +1,26 @@
#pragma once

#include <dds/util/fs.hpp>
#include <dds/util/result.hpp>

#include <neo/concepts.hpp>
#include <neo/sqlite3/database.hpp>
#include <neo/url.hpp>

#include <string_view>
#include <variant>

namespace dds {

class remote_repository {
class pkg_remote {
std::string _name;
neo::url _base_url;

public:
remote_repository(std::string name, neo::url url)
pkg_remote(std::string name, neo::url url)
: _name(std::move(name))
, _base_url(std::move(url)) {}
remote_repository() = default;
pkg_remote() = default;

static remote_repository connect(std::string_view url);
static pkg_remote connect(std::string_view url);

void store(neo::sqlite3::database_ref);
void update_catalog(neo::sqlite3::database_ref);
void update_pkg_db(neo::sqlite3::database_ref);
};

void update_all_remotes(neo::sqlite3::database_ref);

Notiek ielāde…
Atcelt
Saglabāt