feature/exif-endpoint #44

Merged
cameron merged 29 commits from feature/exif-endpoint into master 2025-12-27 03:25:19 +00:00
5 changed files with 24 additions and 7 deletions
Showing only changes of commit df94010d21 - Show all commits

View File

@@ -64,7 +64,6 @@ pub async fn login<D: UserDao>(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::testhelpers::{BodyReader, TestUserDao}; use crate::testhelpers::{BodyReader, TestUserDao};

View File

@@ -819,12 +819,12 @@ impl Handler<RefreshThumbnailsMessage> for StreamActor {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::database::DbError;
use std::collections::HashMap; use std::collections::HashMap;
use std::env; use std::env;
use std::fs::File; use std::fs::File;
use super::*;
struct FakeFileSystem { struct FakeFileSystem {
files: HashMap<String, Vec<String>>, files: HashMap<String, Vec<String>>,
err: bool, err: bool,
@@ -955,6 +955,14 @@ mod tests {
fn get_camera_makes(&mut self) -> Result<Vec<(String, i64)>, crate::database::DbError> { fn get_camera_makes(&mut self) -> Result<Vec<(String, i64)>, crate::database::DbError> {
Ok(Vec::new()) Ok(Vec::new())
} }
fn update_file_path(&mut self, old_path: &str, new_path: &str) -> Result<(), DbError> {
Ok(())
}
fn get_all_file_paths(&mut self) -> Result<Vec<String>, DbError> {
Ok(Vec::new())
}
} }
mod api { mod api {

View File

@@ -12,6 +12,7 @@ use std::f64;
/// ///
/// # Example /// # Example
/// ``` /// ```
/// use image_api::geo::haversine_distance;
/// let distance = haversine_distance(37.7749, -122.4194, 34.0522, -118.2437); /// let distance = haversine_distance(37.7749, -122.4194, 34.0522, -118.2437);
/// // Distance between San Francisco and Los Angeles (~559 km) /// // Distance between San Francisco and Los Angeles (~559 km)
/// ``` /// ```

View File

@@ -15,6 +15,8 @@ pub mod service;
pub mod state; pub mod state;
pub mod tags; pub mod tags;
pub mod video; pub mod video;
#[cfg(test)]
pub mod testhelpers;
// Re-export commonly used types // Re-export commonly used types
pub use data::{Claims, ThumbnailRequest}; pub use data::{Claims, ThumbnailRequest};

View File

@@ -379,7 +379,7 @@ fn collect_exif_memories(
let file_date = timestamp_to_naive_date(*date_taken_ts, client_timezone)?; let file_date = timestamp_to_naive_date(*date_taken_ts, client_timezone)?;
// Check if matches memory criteria // Check if matches memory criteria
if !is_memories_match(file_date, now, span_mode, years_back) { if !is_memories_match(file_path, file_date, now, span_mode, years_back) {
return None; return None;
} }
@@ -438,7 +438,13 @@ fn collect_filesystem_memories(
// Use existing get_file_date_info() for filename/metadata fallback // Use existing get_file_date_info() for filename/metadata fallback
let (file_date, created, modified) = get_file_date_info(entry.path(), client_timezone)?; let (file_date, created, modified) = get_file_date_info(entry.path(), client_timezone)?;
if is_memories_match(file_date, now, span_mode, years_back) { if is_memories_match(
entry.path().to_str().unwrap_or("Unknown"),
file_date,
now,
span_mode,
years_back,
) {
let path_relative = entry.path().strip_prefix(base).ok()?.to_str()?.to_string(); let path_relative = entry.path().strip_prefix(base).ok()?.to_str()?.to_string();
Some(( Some((
@@ -575,6 +581,7 @@ pub async fn list_memories(
} }
fn is_memories_match( fn is_memories_match(
file_path: &str,
file_date: NaiveDate, file_date: NaiveDate,
today: NaiveDate, today: NaiveDate,
span: MemoriesSpan, span: MemoriesSpan,
@@ -586,8 +593,8 @@ fn is_memories_match(
let years_diff = (today.year() - file_date.year()).unsigned_abs(); let years_diff = (today.year() - file_date.year()).unsigned_abs();
if years_diff > years_back { if years_diff > years_back {
warn!( warn!(
"File date is too far in the past: {:?} vs {:?}", "File ({}) date is too far in the past: {:?} vs {:?}",
file_date, today file_path, file_date, today
); );
return false; return false;
} }