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::fmt::Debug;
|
||||||
use std::fs::read_dir;
|
use std::fs::read_dir;
|
||||||
use std::io;
|
use std::io;
|
||||||
@@ -38,7 +37,7 @@ pub async fn list_photos<TagD: TagDao, FS: FileSystemAccess>(
|
|||||||
// Do we need this?
|
// Do we need this?
|
||||||
if let (Some(tag_ids), Some(filter_mode)) = (&req.tag_ids, &req.tag_filter_mode) {
|
if let (Some(tag_ids), Some(filter_mode)) = (&req.tag_ids, &req.tag_filter_mode) {
|
||||||
let search_recursively = &req.recursive.unwrap_or(false);
|
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 mut dao = tag_dao.lock().expect("Unable to get TagDao");
|
||||||
let tag_ids = tag_ids
|
let tag_ids = tag_ids
|
||||||
.split(',')
|
.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))
|
.context(format!("Failed to get files with tag_ids: {:?}", tag_ids))
|
||||||
.map(|tagged_files| {
|
.map(|tagged_files| {
|
||||||
HttpResponse::Ok().json(PhotosResponse {
|
HttpResponse::Ok().json(PhotosResponse {
|
||||||
photos: tagged_files.iter().filter(|&file_path| {
|
photos: tagged_files,
|
||||||
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>>(),
|
|
||||||
dirs: vec![],
|
dirs: vec![],
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user