From 2700ed6a3e1092a064f28b07f8e2c4e5b9b830e7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 16 Nov 2015 20:02:06 +0200 Subject: Implement new URL path schema for the web interface --- loader/loader.cxx | 51 +++++++++++++++++++++------------------------------ loader/options.cli | 32 +++++++++++++++++--------------- 2 files changed, 38 insertions(+), 45 deletions(-) (limited to 'loader') diff --git a/loader/loader.cxx b/loader/loader.cxx index e9f5566..402194c 100644 --- a/loader/loader.cxx +++ b/loader/loader.cxx @@ -2,13 +2,7 @@ // copyright : Copyright (c) 2014-2015 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include -#include // shared_ptr, make_shared() -#include -#include // move() -#include // uint64_t #include -#include #include #include #include // runtime_error, invalid_argument @@ -23,11 +17,12 @@ #include #include -#include // timestamp_nonexistent #include #include // manifest_parsing +#include +#include #include #include @@ -225,11 +220,10 @@ changed (const internal_repositories& repos, database& db) // Check if there is an internal repository not being listed in the // configuration file. // - auto rs ( - db.query ( - query::internal && !query::name.in_range (names.begin (), names.end ()))); - - return !rs.empty (); + return + !db.query ( + query::internal && !query::name.in_range (names.begin (), names.end ())). + empty (); } static timestamp @@ -249,8 +243,6 @@ manifest_stream (const path& p, ifstream& f) static void load_packages (const shared_ptr& rp, database& db) { - using brep::optional; // Ambiguity with butl::optional. - // packages_timestamp other than timestamp_nonexistent signals the // repository packages are already loaded. // @@ -430,6 +422,9 @@ load_repositories (const shared_ptr& rp, database& db) // Can, basically, repository be available on the web but have no web // interface associated ? // + // Yes, there can be no web interface. So we should just not form + // links to packages from such repos. + // if (rp->url) { // Normalize web interface url adding trailing '/' if not present. @@ -607,10 +602,8 @@ resolve_dependencies (package& p, database& db) } } - auto r ( - db.query (q + order_by_version_desc (query::id.version))); - - for (const auto& pp: r) + for (const auto& pp: + db.query (q + order_by_version_desc (query::id.version))) { if (find (p.internal_repository, pp)) { @@ -784,12 +777,14 @@ main (int argc, char* argv[]) // On the first pass over the internal repositories we load their // packages. // + uint16_t priority (1); for (const auto& ir: irs) { shared_ptr r ( make_shared (ir.location, move (ir.display_name), - move (ir.local_path))); + move (ir.local_path), + priority++)); load_packages (r, db); } @@ -811,20 +806,16 @@ main (int argc, char* argv[]) // Resolve internal packages dependencies. // - { - auto r (db.query (query::internal_repository.is_not_null ())); - for (auto& p: r) - resolve_dependencies (p, db); - } + for (auto& p: + db.query (query::internal_repository.is_not_null ())) + resolve_dependencies (p, db); // Ensure there is no package dependency cycles. // - { - package_ids chain; - auto r (db.query (query::internal_repository.is_not_null ())); - for (const auto& p: r) - detect_dependency_cycle (p.id, chain, db); - } + package_ids chain; + for (const auto& p: + db.query (query::internal_repository.is_not_null ())) + detect_dependency_cycle (p.id, chain, db); } t.commit (); diff --git a/loader/options.cli b/loader/options.cli index 9e96585..7045a22 100644 --- a/loader/options.cli +++ b/loader/options.cli @@ -2,23 +2,25 @@ // copyright : Copyright (c) 2014-2015 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -include ; -include ; +include ; -class options +namespace brep { - bool --help {"Print usage information and exit."}; - bool --version {"Print version and exit."}; - - std::string --db-host = "localhost" + class options { - "", - "Connect database server using specified host or socket directory." - }; + bool --help {"Print usage information and exit."}; + bool --version {"Print version and exit."}; - std::uint16_t --db-port = 5432 - { - "", - "Connect database server using specified port." + string --db-host = "localhost" + { + "", + "Connect database server using specified host or socket directory." + }; + + uint16_t --db-port = 5432 + { + "", + "Connect database server using specified port." + }; }; -}; +} -- cgit v1.1