Create file metadata endpoint

This allows retrieving create/modify date as well as file size for any
file in the BASE_PATH.
This commit is contained in:
Cameron Cordes
2021-05-19 08:53:20 -04:00
parent 9a40614d1e
commit 9d823fdc51
4 changed files with 62 additions and 13 deletions

View File

@@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
use path_absolutize::*;
pub fn list_files(dir: PathBuf) -> io::Result<Vec<PathBuf>> {
pub fn list_files(dir: &Path) -> io::Result<Vec<PathBuf>> {
let files = read_dir(dir)?
.map(|res| res.unwrap())
.filter(|entry| is_image_or_video(&entry.path()) || entry.file_type().unwrap().is_dir())
@@ -151,6 +151,13 @@ mod tests {
assert!(is_image_or_video(Path::new("image.MoV")));
}
#[test]
fn nef_valid_extension_test() {
assert!(is_image_or_video(Path::new("image.nef")));
assert!(is_image_or_video(Path::new("image.NEF")));
assert!(is_image_or_video(Path::new("image.NeF")));
}
#[test]
fn hidden_file_not_valid_test() {
assert!(!is_image_or_video(Path::new(".DS_store")));