Resolve TODO: Ref::get_path_hash() should return Result<String>
This commit is contained in:
parent
41aaaf9ddc
commit
7a5134ead2
3 changed files with 5 additions and 5 deletions
|
@ -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",
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue