Fix Ref::get_path_hash() to use ::into_pathbuf()

This commit is contained in:
Matthias Beyer 2016-09-06 12:23:44 +02:00
parent a53adb854d
commit a6377f322e

View file

@ -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