diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-06-18 19:52:42 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-06-18 19:52:42 +0300 |
commit | cd3c920c2153c5e1397683860011df7856a1a0c0 (patch) | |
tree | 2bf66c6ae51f98a7b39635a478b09c74ad933ac4 | |
parent | 4476d9d02ac7af21a7bc6ef92490491d308237f4 (diff) |
Fix assertion failure in rep-remove
-rw-r--r-- | bpkg/rep-remove.cxx | 27 |
1 files changed, 20 insertions, 7 deletions
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<repository_count> () == 0) + assert (db.query_value<repository_fragment_count> () == 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<repository_fragment_count> () == 0) + { + assert (db.query_value<repository_count> () == 0); + assert (db.query_value<available_package_count> () == 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<repository>& 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<repository_count> () != 0 || - (db.query_value<repository_fragment_count> () == 0 && - db.query_value<available_package_count> () == 0)); } void |