From 631489af70b42392657c748eccd2fc3a40a02006 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 1 Jun 2018 16:52:19 +0300 Subject: Fix repeated removal of repository fragment object during rep-fetch --- bpkg/rep-fetch.cxx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/bpkg/rep-fetch.cxx b/bpkg/rep-fetch.cxx index b9b4a23..2de6a01 100644 --- a/bpkg/rep-fetch.cxx +++ b/bpkg/rep-fetch.cxx @@ -1112,8 +1112,24 @@ namespace bpkg // Remove dangling repository fragments. // + // Prior to removing a fragments we need to make sure it still exists, + // which may not be the case due to the containing dangling repository + // removal (see above). + // for (const shared_ptr& rf: removed_fragments) - rep_remove_fragment (conf, t, rf); + { + shared_ptr f ( + db.find (rf->name)); + + if (f != nullptr) + { + // The persisted object must be the same as the one being removed. + // + assert (f == rf); + + rep_remove_fragment (conf, t, rf); + } + } // Finally, make sure that the external packages are available from a // single directory-based repository. -- cgit v1.1