fix(dates): prefer earliest of fs created/modified as fallback

On copied or restored files (e.g. a backup library), the OS stamps
created at copy time while modified is preserved from the source, so
the earlier of the two is a better proxy for when the content
originated. Adds utils::earliest_fs_time and threads it through the
three spots that fall back to filesystem dates: photos-list sort,
memories grouping, and insight-generation timestamp.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cameron
2026-04-23 17:20:12 -04:00
parent d54419e779
commit dc2a96162e
4 changed files with 31 additions and 9 deletions

View File

@@ -19,6 +19,7 @@ use crate::files::is_image_or_video;
use crate::libraries::Library;
use crate::otel::{extract_context_from_request, global_tracer};
use crate::state::AppState;
use crate::utils::earliest_fs_time;
// Helper that encapsulates path-exclusion semantics
#[derive(Debug)]
@@ -336,8 +337,8 @@ fn get_memory_date_with_priority(
return Some((date, Some(exif_timestamp), modified));
}
// Priority 3: Fall back to metadata
let system_time = meta.created().ok().or_else(|| meta.modified().ok())?;
// Priority 3: Fall back to metadata (earlier of created/modified — see utils::earliest_fs_time)
let system_time = earliest_fs_time(&meta)?;
let dt_utc: DateTime<Utc> = system_time.into();
let date_in_timezone = if let Some(tz) = client_timezone {