From 34d9f3429f26cc43ccb50d3c494879009a8f9952 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 19 Feb 2019 23:38:33 +0100 Subject: [PATCH] Add debug output Signed-off-by: Matthias Beyer --- lib/core/libimagstore/src/file_abstraction/fs.rs | 3 +++ lib/core/libimagstore/src/file_abstraction/inmemory.rs | 1 + lib/core/libimagstore/src/file_abstraction/iter.rs | 7 +++++-- lib/core/libimagstore/src/storeid.rs | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/core/libimagstore/src/file_abstraction/fs.rs b/lib/core/libimagstore/src/file_abstraction/fs.rs index f6264337..9877474d 100644 --- a/lib/core/libimagstore/src/file_abstraction/fs.rs +++ b/lib/core/libimagstore/src/file_abstraction/fs.rs @@ -164,17 +164,20 @@ impl FileAbstraction for FSFileAbstraction { } } +#[derive(Debug)] pub struct WalkDirPathIterBuilder { basepath: PathBuf } impl PathIterBuilder for WalkDirPathIterBuilder { fn build_iter(&self) -> Box>> { + trace!("Building iterator for {}", self.basepath.display()); Box::new(WalkDir::new(self.basepath.clone()) .min_depth(1) .max_open(100) .into_iter() .map(|r| { + trace!("Working in PathIterator with {:?}", r); r.map(|e| PathBuf::from(e.path())) .context(format_err!("Error in Walkdir")) .map_err(Error::from) diff --git a/lib/core/libimagstore/src/file_abstraction/inmemory.rs b/lib/core/libimagstore/src/file_abstraction/inmemory.rs index 43dddb0c..603f4dbd 100644 --- a/lib/core/libimagstore/src/file_abstraction/inmemory.rs +++ b/lib/core/libimagstore/src/file_abstraction/inmemory.rs @@ -203,6 +203,7 @@ impl FileAbstraction for InMemoryFileAbstraction { } } +#[derive(Debug)] pub struct InMemPathIterBuilder(Vec); impl PathIterBuilder for InMemPathIterBuilder { diff --git a/lib/core/libimagstore/src/file_abstraction/iter.rs b/lib/core/libimagstore/src/file_abstraction/iter.rs index 2eda4c27..6bd476a1 100644 --- a/lib/core/libimagstore/src/file_abstraction/iter.rs +++ b/lib/core/libimagstore/src/file_abstraction/iter.rs @@ -19,6 +19,7 @@ use std::path::PathBuf; use std::sync::Arc; +use std::fmt::Debug; use failure::Fallible as Result; @@ -26,7 +27,7 @@ use storeid::StoreIdWithBase; use file_abstraction::FileAbstraction; /// See documentation for PathIterator -pub(crate) trait PathIterBuilder { +pub(crate) trait PathIterBuilder : Debug { fn build_iter(&self) -> Box>>; fn in_collection(&mut self, c: &str); } @@ -59,7 +60,7 @@ impl<'a> PathIterator<'a> { backend: Arc) -> PathIterator<'a> { - trace!("Generating iterator object with PathIterBuilder"); + trace!("Generating iterator object with PathIterBuilder: {:?}", iter_builder); let iter = iter_builder.build_iter(); PathIterator { iter_builder, iter, storepath, backend } } @@ -68,6 +69,7 @@ impl<'a> PathIterator<'a> { trace!("Generating iterator object for collection: {}", c); self.iter_builder.in_collection(c); self.iter = self.iter_builder.build_iter(); + trace!("Set new iterator"); self } @@ -90,6 +92,7 @@ impl<'a> Iterator for PathIterator<'a> { fn next(&mut self) -> Option { while let Some(next) = self.iter.next() { + trace!("Iterating over item = {:?}", next); match next { Err(e) => return Some(Err(e)), Ok(next) => match self.backend.is_file(&next) { diff --git a/lib/core/libimagstore/src/storeid.rs b/lib/core/libimagstore/src/storeid.rs index d0a7d396..f269c39b 100644 --- a/lib/core/libimagstore/src/storeid.rs +++ b/lib/core/libimagstore/src/storeid.rs @@ -179,6 +179,9 @@ impl<'a> StoreIdWithBase<'a> { pub(crate) fn from_full_path(store_part: &'a PathBuf, full_path: D) -> Result> where D: Deref { + trace!("Creating StoreIdWithBase object from full path = {} with store_part = {}", + full_path.display(), + store_part.display()); let p = full_path .strip_prefix(store_part) .map_err(Error::from)