diff --git a/libimagref/src/reference.rs b/libimagref/src/reference.rs index 8df36f93..15a89734 100644 --- a/libimagref/src/reference.rs +++ b/libimagref/src/reference.rs @@ -15,6 +15,7 @@ use libimagstore::storeid::StoreId; use libimagstore::storeid::IntoStoreId; use libimagstore::store::Store; use libimagerror::into::IntoError; +use libimagerror::trace::MapErrTrace; use toml::Value; @@ -230,11 +231,18 @@ impl<'a> Ref<'a> { /// Get the hash from the path of the ref pub fn get_path_hash(&self) -> Option { - let pb : PathBuf = self.0.get_location().clone().into(); - pb.file_name() - .and_then(|osstr| osstr.to_str()) - .and_then(|s| s.split("~").next()) - .map(String::from) + self.0 + .get_location() + .clone() + .into_pathbuf() + .map_err_trace() + .ok() // TODO: Hiding the error here is not so nice + .and_then(|pb| { + pb.file_name() + .and_then(|osstr| osstr.to_str()) + .and_then(|s| s.split("~").next()) + .map(String::from) + }) } /// Get the hash of the link target which is stored in the ref object