feature/add-recursive-tag-support #26

Merged
cameron merged 3 commits from feature/add-recursive-tag-support into master 2024-03-09 18:14:51 +00:00
Showing only changes of commit b2c8ebe558 - Show all commits

View File

@@ -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![],
})
})