diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-06-01 16:52:19 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-06-01 16:52:19 +0300 |
commit | 631489af70b42392657c748eccd2fc3a40a02006 (patch) | |
tree | 705035b9fbe6e67a699bd301d050f87f83c1b541 | |
parent | 0cb15e956256894834f4630234a76402b87855a2 (diff) |
Fix repeated removal of repository fragment object during rep-fetch
-rw-r--r-- | bpkg/rep-fetch.cxx | 18 |
1 files changed, 17 insertions, 1 deletions
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<repository_fragment>& rf: removed_fragments) - rep_remove_fragment (conf, t, rf); + { + shared_ptr<repository_fragment> f ( + db.find<repository_fragment> (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. |