Fix tests and improve memories date error log
This commit is contained in:
@@ -64,7 +64,6 @@ pub async fn login<D: UserDao>(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use super::*;
|
||||
use crate::testhelpers::{BodyReader, TestUserDao};
|
||||
|
||||
|
||||
12
src/files.rs
12
src/files.rs
@@ -819,12 +819,12 @@ impl Handler<RefreshThumbnailsMessage> for StreamActor {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::database::DbError;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
|
||||
use super::*;
|
||||
|
||||
struct FakeFileSystem {
|
||||
files: HashMap<String, Vec<String>>,
|
||||
err: bool,
|
||||
@@ -955,6 +955,14 @@ mod tests {
|
||||
fn get_camera_makes(&mut self) -> Result<Vec<(String, i64)>, crate::database::DbError> {
|
||||
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 {
|
||||
|
||||
@@ -12,6 +12,7 @@ use std::f64;
|
||||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// use image_api::geo::haversine_distance;
|
||||
/// let distance = haversine_distance(37.7749, -122.4194, 34.0522, -118.2437);
|
||||
/// // Distance between San Francisco and Los Angeles (~559 km)
|
||||
/// ```
|
||||
|
||||
@@ -15,6 +15,8 @@ pub mod service;
|
||||
pub mod state;
|
||||
pub mod tags;
|
||||
pub mod video;
|
||||
#[cfg(test)]
|
||||
pub mod testhelpers;
|
||||
|
||||
// Re-export commonly used types
|
||||
pub use data::{Claims, ThumbnailRequest};
|
||||
|
||||
@@ -379,7 +379,7 @@ fn collect_exif_memories(
|
||||
let file_date = timestamp_to_naive_date(*date_taken_ts, client_timezone)?;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -438,7 +438,13 @@ fn collect_filesystem_memories(
|
||||
// Use existing get_file_date_info() for filename/metadata fallback
|
||||
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();
|
||||
|
||||
Some((
|
||||
@@ -575,6 +581,7 @@ pub async fn list_memories(
|
||||
}
|
||||
|
||||
fn is_memories_match(
|
||||
file_path: &str,
|
||||
file_date: NaiveDate,
|
||||
today: NaiveDate,
|
||||
span: MemoriesSpan,
|
||||
@@ -586,8 +593,8 @@ fn is_memories_match(
|
||||
let years_diff = (today.year() - file_date.year()).unsigned_abs();
|
||||
if years_diff > years_back {
|
||||
warn!(
|
||||
"File date is too far in the past: {:?} vs {:?}",
|
||||
file_date, today
|
||||
"File ({}) date is too far in the past: {:?} vs {:?}",
|
||||
file_path, file_date, today
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user