details: filter is only used when recursing

So move it as part of 'recurse's option.
This commit is contained in:
Ben S 2015-02-26 07:26:04 +00:00
parent abf7bf7a3e
commit f9f1c991cb
2 changed files with 4 additions and 6 deletions

View File

@ -233,9 +233,8 @@ impl View {
let details = Details {
columns: try!(Columns::deduce(matches)),
header: matches.opt_present("header"),
recurse: dir_action.recurse_options(),
recurse: dir_action.recurse_options().map(|o| (o, filter)),
xattr: xattr::feature_implemented() && matches.opt_present("extended"),
filter: filter,
};
Ok(View::Details(details))

View File

@ -12,9 +12,8 @@ use ansi_term::Style::Plain;
pub struct Details {
pub columns: Columns,
pub header: bool,
pub recurse: Option<RecurseOptions>,
pub recurse: Option<(RecurseOptions, FileFilter)>,
pub xattr: bool,
pub filter: FileFilter,
}
impl Details {
@ -41,14 +40,14 @@ impl Details {
for (index, file) in src.iter().enumerate() {
table.add_row(file, depth, index == src.len() - 1);
if let Some(r) = self.recurse {
if let Some((r, filter)) = self.recurse {
if r.tree == false || r.is_too_deep(depth) {
continue;
}
if let Some(ref dir) = file.this {
let mut files = dir.files(true);
self.filter.transform_files(&mut files);
filter.transform_files(&mut files);
self.add_files_to_table(table, &files, depth + 1);
}
}