From 9cf78972862c200877e94a8cef437eb04069bcd3 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 22 Aug 2016 12:07:50 +0200 Subject: [PATCH] Fixup Walk type to handle StoreId properly --- libimagstore/src/store.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index 3f344f5c..14e5ecd0 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -65,14 +65,17 @@ pub enum StoreObject { } pub struct Walk { + store_path: PathBuf, dirwalker: WalkDirIter, } impl Walk { fn new(mut store_path: PathBuf, mod_name: &str) -> Walk { + let pb = store_path.clone(); store_path.push(mod_name); Walk { + store_path: pb, dirwalker: WalkDir::new(store_path).into_iter(), } } @@ -95,7 +98,9 @@ impl Iterator for Walk { Ok(next) => if next.file_type().is_dir() { return Some(StoreObject::Collection(next.path().to_path_buf())) } else if next.file_type().is_file() { - return Some(StoreObject::Id(next.path().to_path_buf().into())) + let n = next.path().to_path_buf(); + let sid = StoreId::new(Some(self.store_path.clone()), n); + return Some(StoreObject::Id(sid)) }, Err(e) => { warn!("Error in Walker");