Add debug output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
0a62548173
commit
34d9f3429f
4 changed files with 12 additions and 2 deletions
|
@ -164,17 +164,20 @@ impl FileAbstraction for FSFileAbstraction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct WalkDirPathIterBuilder {
|
pub struct WalkDirPathIterBuilder {
|
||||||
basepath: PathBuf
|
basepath: PathBuf
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PathIterBuilder for WalkDirPathIterBuilder {
|
impl PathIterBuilder for WalkDirPathIterBuilder {
|
||||||
fn build_iter(&self) -> Box<Iterator<Item = Result<PathBuf>>> {
|
fn build_iter(&self) -> Box<Iterator<Item = Result<PathBuf>>> {
|
||||||
|
trace!("Building iterator for {}", self.basepath.display());
|
||||||
Box::new(WalkDir::new(self.basepath.clone())
|
Box::new(WalkDir::new(self.basepath.clone())
|
||||||
.min_depth(1)
|
.min_depth(1)
|
||||||
.max_open(100)
|
.max_open(100)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|r| {
|
.map(|r| {
|
||||||
|
trace!("Working in PathIterator with {:?}", r);
|
||||||
r.map(|e| PathBuf::from(e.path()))
|
r.map(|e| PathBuf::from(e.path()))
|
||||||
.context(format_err!("Error in Walkdir"))
|
.context(format_err!("Error in Walkdir"))
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
|
|
|
@ -203,6 +203,7 @@ impl FileAbstraction for InMemoryFileAbstraction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct InMemPathIterBuilder(Vec<PathBuf>);
|
pub struct InMemPathIterBuilder(Vec<PathBuf>);
|
||||||
|
|
||||||
impl PathIterBuilder for InMemPathIterBuilder {
|
impl PathIterBuilder for InMemPathIterBuilder {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::fmt::Debug;
|
||||||
|
|
||||||
use failure::Fallible as Result;
|
use failure::Fallible as Result;
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ use storeid::StoreIdWithBase;
|
||||||
use file_abstraction::FileAbstraction;
|
use file_abstraction::FileAbstraction;
|
||||||
|
|
||||||
/// See documentation for PathIterator
|
/// See documentation for PathIterator
|
||||||
pub(crate) trait PathIterBuilder {
|
pub(crate) trait PathIterBuilder : Debug {
|
||||||
fn build_iter(&self) -> Box<Iterator<Item = Result<PathBuf>>>;
|
fn build_iter(&self) -> Box<Iterator<Item = Result<PathBuf>>>;
|
||||||
fn in_collection(&mut self, c: &str);
|
fn in_collection(&mut self, c: &str);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +60,7 @@ impl<'a> PathIterator<'a> {
|
||||||
backend: Arc<FileAbstraction>)
|
backend: Arc<FileAbstraction>)
|
||||||
-> PathIterator<'a>
|
-> PathIterator<'a>
|
||||||
{
|
{
|
||||||
trace!("Generating iterator object with PathIterBuilder");
|
trace!("Generating iterator object with PathIterBuilder: {:?}", iter_builder);
|
||||||
let iter = iter_builder.build_iter();
|
let iter = iter_builder.build_iter();
|
||||||
PathIterator { iter_builder, iter, storepath, backend }
|
PathIterator { iter_builder, iter, storepath, backend }
|
||||||
}
|
}
|
||||||
|
@ -68,6 +69,7 @@ impl<'a> PathIterator<'a> {
|
||||||
trace!("Generating iterator object for collection: {}", c);
|
trace!("Generating iterator object for collection: {}", c);
|
||||||
self.iter_builder.in_collection(c);
|
self.iter_builder.in_collection(c);
|
||||||
self.iter = self.iter_builder.build_iter();
|
self.iter = self.iter_builder.build_iter();
|
||||||
|
trace!("Set new iterator");
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +92,7 @@ impl<'a> Iterator for PathIterator<'a> {
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
while let Some(next) = self.iter.next() {
|
while let Some(next) = self.iter.next() {
|
||||||
|
trace!("Iterating over item = {:?}", next);
|
||||||
match next {
|
match next {
|
||||||
Err(e) => return Some(Err(e)),
|
Err(e) => return Some(Err(e)),
|
||||||
Ok(next) => match self.backend.is_file(&next) {
|
Ok(next) => match self.backend.is_file(&next) {
|
||||||
|
|
|
@ -179,6 +179,9 @@ impl<'a> StoreIdWithBase<'a> {
|
||||||
pub(crate) fn from_full_path<D>(store_part: &'a PathBuf, full_path: D) -> Result<StoreIdWithBase<'a>>
|
pub(crate) fn from_full_path<D>(store_part: &'a PathBuf, full_path: D) -> Result<StoreIdWithBase<'a>>
|
||||||
where D: Deref<Target = Path>
|
where D: Deref<Target = Path>
|
||||||
{
|
{
|
||||||
|
trace!("Creating StoreIdWithBase object from full path = {} with store_part = {}",
|
||||||
|
full_path.display(),
|
||||||
|
store_part.display());
|
||||||
let p = full_path
|
let p = full_path
|
||||||
.strip_prefix(store_part)
|
.strip_prefix(store_part)
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
|
|
Loading…
Reference in a new issue