From c9612437fd4ffecd460ee4bdcb8a9b77a1e94d76 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 25 Aug 2016 19:48:02 +0200 Subject: [PATCH] Fix libimagentryview::builtin::versions::* for new StoreId interface --- libimagentryview/src/builtin/versions.rs | 30 +++++++++++++----------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/libimagentryview/src/builtin/versions.rs b/libimagentryview/src/builtin/versions.rs index 11439c36..1b09b332 100644 --- a/libimagentryview/src/builtin/versions.rs +++ b/libimagentryview/src/builtin/versions.rs @@ -5,6 +5,7 @@ use libimagerror::into::IntoError; use viewer::Viewer; use result::Result; use error::ViewErrorKind as VEK; +use error::MapErrInto; pub struct VersionsViewer<'a> { store: &'a Store, @@ -27,27 +28,28 @@ impl<'a> Viewer for VersionsViewer<'a> { entr.get_location() .clone() - .storified(self.store) + .with_base(self.store.path().clone()) .to_str() - .and_then(|s| s.split("~").next()) - .map(|component| { - glob(&format!("{}~*", component)[..]) - .map_err(|_| VEK::PatternError.into_error()) + .map_err_into(VEK::ViewError) + .and_then(|s| { + s.split("~") + .next() + .ok_or(VEK::PatternError.into_error()) + .map(|s| format!("{}~*", s)) + .and_then(|pat| glob(&pat[..]).map_err(|_| VEK::PatternError.into_error())) .and_then(|paths| { for entry in paths { - let p = match entry { - Err(_) => return Err(VEK::GlobError.into_error()), - Ok(p) => p, - }; - let p = p.file_name() - .and_then(|s| s.to_str()) - .unwrap(); // TODO - println!("{}", p); + println!("{}", + try!(entry + .map_err(|_| VEK::GlobError.into_error())) + .file_name() + .and_then(|s| s.to_str()) + .unwrap() // TODO + ); }; Ok(()) }) }) - .unwrap_or(Err(VEK::PatternBuildingError.into_error())) } }