From 429ef9bc4c1ff6bd16188b251a59b95a5beea949 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 13 Dec 2018 01:28:01 +0100 Subject: [PATCH] Fix libimagentrylink for new StoreId API Signed-off-by: Matthias Beyer --- lib/entry/libimagentrylink/src/internal.rs | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/entry/libimagentrylink/src/internal.rs b/lib/entry/libimagentrylink/src/internal.rs index 7b092d24..65277095 100644 --- a/lib/entry/libimagentrylink/src/internal.rs +++ b/lib/entry/libimagentrylink/src/internal.rs @@ -80,9 +80,9 @@ impl Link { /// Helper wrapper around Link for StoreId fn without_base(self) -> Link { match self { - Link::Id { link: s } => Link::Id { link: s.without_base() }, + Link::Id { link: s } => Link::Id { link: s }, Link::Annotated { link: s, annotation: ann } => - Link::Annotated { link: s.without_base(), annotation: ann }, + Link::Annotated { link: s, annotation: ann }, } } @@ -435,24 +435,24 @@ impl InternalLinker for Entry { fn remove_internal_link(&mut self, link: &mut Entry) -> Result<()> { debug!("Removing internal link: {:?}", link); - let own_loc = self.get_location().clone().without_base(); - let other_loc = link.get_location().clone().without_base(); + + // Cloning because of borrowing + let own_loc = self.get_location().clone(); + let other_loc = link.get_location().clone(); debug!("Removing internal link from {:?} to {:?}", own_loc, other_loc); - link.get_internal_links() + let links = link.get_internal_links()?; + debug!("Rewriting own links for {:?}, without {:?}", other_loc, own_loc); + + let links = links.filter(|l| !l.eq_store_id(&own_loc)); + let _ = rewrite_links(link.get_header_mut(), links)?; + + self.get_internal_links() .and_then(|links| { - debug!("Rewriting own links for {:?}, without {:?}", other_loc, own_loc); - let links = links.filter(|l| !l.eq_store_id(&own_loc)); - rewrite_links(link.get_header_mut(), links) - }) - .and_then(|_| { - self.get_internal_links() - .and_then(|links| { - debug!("Rewriting own links for {:?}, without {:?}", own_loc, other_loc); - let links = links.filter(|l| !l.eq_store_id(&other_loc)); - rewrite_links(self.get_header_mut(), links) - }) + debug!("Rewriting own links for {:?}, without {:?}", own_loc, other_loc); + let links = links.filter(|l| !l.eq_store_id(&other_loc)); + rewrite_links(self.get_header_mut(), links) }) } @@ -682,7 +682,7 @@ pub mod store_check { if is_match!(self.get(id.clone()), Ok(Some(_))) { debug!("Exists in store: {:?}", id); - if !id.exists()? { + if !self.exists(id.clone())? { warn!("Does exist in store but not on FS: {:?}", id); return Err(err_msg("Link target does not exist")) }