From ccd8c8dadfcfd9181772b3061e7b075d88942505 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 7 Mar 2018 22:36:57 +0300 Subject: Change database parameter type to transaction for some rep_*() functions --- bpkg/rep-remove.cxx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'bpkg/rep-remove.cxx') diff --git a/bpkg/rep-remove.cxx b/bpkg/rep-remove.cxx index df9acde..eadb63f 100644 --- a/bpkg/rep-remove.cxx +++ b/bpkg/rep-remove.cxx @@ -72,8 +72,10 @@ namespace bpkg } void - rep_remove_package_locations (database& db, const string& name) + rep_remove_package_locations (transaction& t, const string& name) { + database& db (t.database ()); + for (const auto& rp: db.query ( query::repository::name == name)) { @@ -112,15 +114,19 @@ namespace bpkg } void - rep_remove (const dir_path& c, database& db, const shared_ptr& r) + rep_remove (const dir_path& c, + transaction& t, + const shared_ptr& r) { const string& nm (r->name); assert (!nm.empty ()); // Can't be the root repository. + database& db (t.database ()); + if (reachable (db, r)) return; - rep_remove_package_locations (db, nm); + rep_remove_package_locations (t, nm); // Cleanup the repository state if present. // @@ -154,12 +160,12 @@ namespace bpkg // Prior to removing a prerequisite/complement we need to make sure it // still exists, which may not be the case due to the dependency cycle. // - auto remove = [&c, &db] (const lazy_shared_ptr& rp) + auto remove = [&c, &db, &t] (const lazy_shared_ptr& rp) { shared_ptr r (db.find (rp.object_id ())); if (r) - rep_remove (c, db, r); + rep_remove (c, t, r); }; for (const lazy_shared_ptr& cr: r->complements) @@ -375,7 +381,7 @@ namespace bpkg // for (const lazy_shared_ptr& r: repos) { - rep_remove (c, db, r.load ()); + rep_remove (c, t, r.load ()); if (verb) text << "removed " << r.object_id (); -- cgit v1.1