Move tag filtering to sub-function
This commit is contained in:
parent
e8c7df4593
commit
80563cb340
1 changed files with 12 additions and 7 deletions
|
@ -123,6 +123,17 @@ fn get_filtered_files_from_backend<'a>(module: &'a Module,
|
|||
env: &CommandEnv)
|
||||
-> Result<IntoIter<File<'a>>, ModuleError>
|
||||
{
|
||||
fn check_tags(tags: &Vec<String>, file: &File) -> bool {
|
||||
if tags.len() != 0 {
|
||||
debug!("Checking tags of: {:?}", file.id());
|
||||
get_tags_from_header(&file.header())
|
||||
.iter()
|
||||
.any(|t| tags.contains(t))
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
let parser = Parser::new(JsonHeaderParser::new(None));
|
||||
let tags = get_tags(env.rt, env.matches);
|
||||
debug!("Tags: {:?}", tags);
|
||||
|
@ -130,13 +141,7 @@ fn get_filtered_files_from_backend<'a>(module: &'a Module,
|
|||
.map(|files| {
|
||||
let f = files.filter(|file| {
|
||||
debug!("Backend returns file: {:?}", file);
|
||||
if tags.len() != 0 {
|
||||
debug!("Checking tags of: {:?}", file.id());
|
||||
get_tags_from_header(&file.header()).iter()
|
||||
.any(|t| tags.contains(t))
|
||||
} else {
|
||||
true
|
||||
}
|
||||
check_tags(&tags, file)
|
||||
}).filter(|file| {
|
||||
debug!("Checking matches of: {:?}", file.id());
|
||||
get_matcher(env.rt, env.matches)
|
||||
|
|
Loading…
Reference in a new issue