From 1dd40ca8b9d9557beda3ffddfb5109a77c8f2843 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 14 Jul 2016 21:04:46 +0200 Subject: [PATCH 1/2] Temporary fix: Check whether an StoreId is an external link by str::contains() This is a temporary fix as long as we do not have a clear model how we handle internal/external StoreId types --- libimagentrylink/src/external.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libimagentrylink/src/external.rs b/libimagentrylink/src/external.rs index 01f6badb..a9df5f87 100644 --- a/libimagentrylink/src/external.rs +++ b/libimagentrylink/src/external.rs @@ -97,7 +97,7 @@ pub trait ExternalLinker : InternalLinker { /// Check whether the StoreId starts with `/link/external/` pub fn is_external_link_storeid(id: &StoreId) -> bool { debug!("Checking whether this is a /link/external/*: '{:?}'", id); - id.starts_with("/link/external/") + id.to_str().map(|s| s.contains("/link/external/")).unwrap_or(false) } fn get_external_link_from_file(entry: &FileLockEntry) -> Result { From 3f2ababdb0e16e3b638147002ba470e66060c0fd Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 14 Jul 2016 21:27:36 +0200 Subject: [PATCH 2/2] Add more robust version of is_external_link_storeid() helper function --- libimagentrylink/src/external.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libimagentrylink/src/external.rs b/libimagentrylink/src/external.rs index a9df5f87..fab878b9 100644 --- a/libimagentrylink/src/external.rs +++ b/libimagentrylink/src/external.rs @@ -97,7 +97,7 @@ pub trait ExternalLinker : InternalLinker { /// Check whether the StoreId starts with `/link/external/` pub fn is_external_link_storeid(id: &StoreId) -> bool { debug!("Checking whether this is a /link/external/*: '{:?}'", id); - id.to_str().map(|s| s.contains("/link/external/")).unwrap_or(false) + id.parent().map(|par| par.ends_with("/link/external")).unwrap_or(false) } fn get_external_link_from_file(entry: &FileLockEntry) -> Result {