summaryrefslogtreecommitdiffstats
path: root/libimagref
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-09-06 12:23:44 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-09-06 15:31:55 +0200
commita6377f322e270d87951053280ce021f47e4c0ebc (patch)
tree3af2b3748260872acf0a773e76910f0ea401bec9 /libimagref
parenta53adb854dd0557de4b37d2e03c66fac29723e21 (diff)
Fix Ref::get_path_hash() to use ::into_pathbuf()
Diffstat (limited to 'libimagref')
-rw-r--r--libimagref/src/reference.rs18
1 files changed, 13 insertions, 5 deletions
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<String> {
- 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