From cd3c920c2153c5e1397683860011df7856a1a0c0 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 18 Jun 2020 19:52:42 +0300 Subject: Fix assertion failure in rep-remove --- bpkg/rep-remove.cxx | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'bpkg') diff --git a/bpkg/rep-remove.cxx b/bpkg/rep-remove.cxx index cb4d428..c0b67b6 100644 --- a/bpkg/rep-remove.cxx +++ b/bpkg/rep-remove.cxx @@ -167,6 +167,12 @@ namespace bpkg for (const repository::fragment_type& fr: r->fragments) rep_remove_fragment (c, t, fr.fragment.load ()); + // If there are no repositories stayed in the database then no repository + // fragments should stay either. + // + if (db.query_value () == 0) + assert (db.query_value () == 0); + // Cleanup the repository state if present and there are no more // repositories referring this state. // @@ -241,6 +247,20 @@ namespace bpkg // db.erase (rf); + // If there are no repository fragments stayed in the database then no + // repositories nor packages should stay either. + // + // Note that a repository is removed prior to the removal of fragments it + // contains (see rep_remove()). Also note that the packages contained in a + // repository fragment are removed, if this is the only containing + // fragment, prior to the fragment removal (see above). + // + if (db.query_value () == 0) + { + assert (db.query_value () == 0); + assert (db.query_value () == 0); + } + // Remove dangling complements and prerequisites. // // Prior to removing a prerequisite/complement we need to make sure it @@ -263,13 +283,6 @@ namespace bpkg for (const lazy_weak_ptr& pr: rf->prerequisites) remove (pr); - - // If there are no repositories stayed in the database then no repository - // fragments nor packages should stay either. - // - assert (db.query_value () != 0 || - (db.query_value () == 0 && - db.query_value () == 0)); } void -- cgit v1.1