summaryrefslogtreecommitdiffstats
path: root/libimagref
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-10-19 20:05:02 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-10-20 18:30:44 +0200
commit7a5134ead26a32645e5a7a2237653e7506cca69e (patch)
tree4e1b844a96e63aef870e5e56e8a53023c256c1f3 /libimagref
parent41aaaf9ddc5af54bf853efb98df0add0b08c00d2 (diff)
Resolve TODO: Ref::get_path_hash() should return Result<String>
Diffstat (limited to 'libimagref')
-rw-r--r--libimagref/src/error.rs1
-rw-r--r--libimagref/src/lister.rs2
-rw-r--r--libimagref/src/reference.rs7
3 files changed, 5 insertions, 5 deletions
diff --git a/libimagref/src/error.rs b/libimagref/src/error.rs
index a133e8a5..4f782f6c 100644
--- a/libimagref/src/error.rs
+++ b/libimagref/src/error.rs
@@ -23,6 +23,7 @@ generate_error_module!(
StoreWriteError => "Store write error",
IOError => "IO Error",
UTF8Error => "UTF8 Error",
+ StoreIdError => "Error with storeid",
HeaderTypeError => "Header type error",
HeaderFieldMissingError => "Header field missing error",
HeaderFieldWriteError => "Header field cannot be written",
diff --git a/libimagref/src/lister.rs b/libimagref/src/lister.rs
index 94eac2a6..662ea9f6 100644
--- a/libimagref/src/lister.rs
+++ b/libimagref/src/lister.rs
@@ -146,7 +146,7 @@ fn lister_fn(fle: FileLockEntry,
is_changed,
is_changed_content,
is_changed_permiss,
- r.get_path_hash().unwrap_or_else(|| String::from("Cannot get hash")),
+ r.get_path_hash().unwrap_or_else(|_| String::from("Cannot get hash")),
r.get_location())
})
.map_err(|e| LEK::FormatError.into_error_with_cause(Box::new(e)))
diff --git a/libimagref/src/reference.rs b/libimagref/src/reference.rs
index 113e2636..7d732256 100644
--- a/libimagref/src/reference.rs
+++ b/libimagref/src/reference.rs
@@ -34,7 +34,6 @@ use libimagstore::storeid::StoreId;
use libimagstore::storeid::IntoStoreId;
use libimagstore::store::Store;
use libimagerror::into::IntoError;
-use libimagerror::trace::MapErrTrace;
use toml::Value;
@@ -249,18 +248,18 @@ impl<'a> Ref<'a> {
}
/// Get the hash from the path of the ref
- pub fn get_path_hash(&self) -> Option<String> {
+ pub fn get_path_hash(&self) -> Result<String> {
self.0
.get_location()
.clone()
.into_pathbuf()
- .map_err_trace()
- .ok() // TODO: Hiding the error here is not so nice
+ .map_err_into(REK::StoreIdError)
.and_then(|pb| {
pb.file_name()
.and_then(|osstr| osstr.to_str())
.and_then(|s| s.split("~").next())
.map(String::from)
+ .ok_or(REK::StoreIdError.into_error())
})
}