summaryrefslogtreecommitdiffstats
path: root/libimagentrylink
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-08-25 18:49:26 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-08-28 18:41:55 +0200
commitaeb95b1e119c68d37c8a190898ec9844782505df (patch)
tree29f86f0aac67eede46fba85a380f8dde402fa9db /libimagentrylink
parentd252623b7582d91708885ed9d1486d0881c74f5d (diff)
Fix libimagentrylink::external::* for new StoreId interface
Diffstat (limited to 'libimagentrylink')
-rw-r--r--libimagentrylink/src/external.rs20
1 files changed, 17 insertions, 3 deletions
diff --git a/libimagentrylink/src/external.rs b/libimagentrylink/src/external.rs
index a92b8af1..11c524a0 100644
--- a/libimagentrylink/src/external.rs
+++ b/libimagentrylink/src/external.rs
@@ -91,8 +91,16 @@ 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.parent().map(|par| par.ends_with("/link/external")).unwrap_or(false)
+ use std::path::Component;
+
+ debug!("Checking whether this is a link/external/*: '{:?}'", id);
+ id.components()
+ .take(2)
+ .zip(&["link", "external"])
+ .map(|(c, pred)| match c {
+ Component::Normal(ref s) => s.to_str().map(|ref s| s == pred).unwrap_or(false),
+ _ => false
+ }).all(|x| x)
}
fn get_external_link_from_file(entry: &FileLockEntry) -> Result<Url> {
@@ -144,7 +152,13 @@ impl ExternalLinker for Entry {
s.input_str(&link.as_str()[..]);
s.result_str()
};
- let file_id = ModuleEntryPath::new(format!("external/{}", hash)).into_storeid();
+ let file_id = try!(
+ ModuleEntryPath::new(format!("external/{}", hash)).into_storeid()
+ .map_err_into(LEK::StoreWriteError)
+ .map_dbg_err(|_| {
+ format!("Failed to build StoreId for this hash '{:?}'", hash)
+ })
+ );
debug!("Link = '{:?}'", link);
debug!("Hash = '{:?}'", hash);