Break-up FilterMode.All being recursive
Filtering on tags needs some reworking to handle recursive with All or Any filtering.
This commit is contained in:
10
src/files.rs
10
src/files.rs
@@ -1,4 +1,3 @@
|
||||
|
||||
use std::fmt::Debug;
|
||||
use std::fs::read_dir;
|
||||
use std::io;
|
||||
@@ -38,7 +37,7 @@ pub async fn list_photos<TagD: TagDao, FS: FileSystemAccess>(
|
||||
// Do we need this?
|
||||
if let (Some(tag_ids), Some(filter_mode)) = (&req.tag_ids, &req.tag_filter_mode) {
|
||||
let search_recursively = &req.recursive.unwrap_or(false);
|
||||
if *filter_mode == FilterMode::All {
|
||||
if search_recursively {
|
||||
let mut dao = tag_dao.lock().expect("Unable to get TagDao");
|
||||
let tag_ids = tag_ids
|
||||
.split(',')
|
||||
@@ -50,12 +49,7 @@ pub async fn list_photos<TagD: TagDao, FS: FileSystemAccess>(
|
||||
.context(format!("Failed to get files with tag_ids: {:?}", tag_ids))
|
||||
.map(|tagged_files| {
|
||||
HttpResponse::Ok().json(PhotosResponse {
|
||||
photos: tagged_files.iter().filter(|&file_path| {
|
||||
let slash_count = file_path.split('/').count();
|
||||
let search_path_slash_count = path.split('/').count();
|
||||
|
||||
slash_count > search_path_slash_count
|
||||
}).map(|p| p.clone()).collect::<Vec<String>>(),
|
||||
photos: tagged_files,
|
||||
dirs: vec![],
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user