Redirect manual date edits on a version path to its original (#194)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cameron CordesandClaude Opus 5.5 committed 2026-10-30 19:26:37 -04:00
1 parent 0e1fdd43e5
commit 51600f900d
3 files changed
+129 -2

No files matched your search

+68
View File
@@ -462,6 +462,74 @@ async fn folders_holding_only_hidden_versions_are_left_out_of_dirs() {
);
}
#[actix_rt::test]
async fn a_manual_date_on_a_version_path_lands_on_the_original() {
let (fx, original, v1, _v2) = seeded();
fx.exec(&format!(
"UPDATE image_exif SET date_taken = 1500000000, date_utc = 1500000000, \
date_taken_source = 'exif' WHERE content_hash = '{original}'"
));
let app = awtest::init_service(
App::new()
.service(crate::handlers::image::set_image_date)
.service(crate::handlers::image::clear_image_date)
.app_data(fx.state.clone())
.app_data(fx.exif.clone()),
)
.await;
let post = |uri: &str, body: serde_json::Value| {
awtest::TestRequest::post()
.uri(uri)
.insert_header(("Authorization", format!("Bearer {}", Fx::token())))
.set_json(body)
.to_request()
};
let resp = awtest::call_service(
&app,
post(
"/image/exif/date",
serde_json::json!({"path": "2004/aiedits/scan.jpg.restored.png", "date_taken": 1_400_000_000}),
),
)
.await;
assert_eq!(resp.status().as_u16(), 200);
assert_eq!(
fx.count(&format!(
"SELECT COUNT(*) AS n FROM image_exif WHERE content_hash = '{original}' \
AND date_taken_source = 'manual'"
)),
1,
"the original carries the manual date"
);
assert_eq!(
fx.count(&format!(
"SELECT COUNT(*) AS n FROM image_exif WHERE content_hash = '{v1}' \
AND date_taken_source = 'manual'"
)),
0,
"the version row is left to the metadata sync"
);
// The same redirect applies to clearing it.
let resp = awtest::call_service(
&app,
post(
"/image/exif/date/clear",
serde_json::json!({"path": "2004/aiedits/scan.jpg.restored.png"}),
),
)
.await;
assert!(resp.status().is_success());
assert_eq!(
fx.count(&format!(
"SELECT COUNT(*) AS n FROM image_exif WHERE content_hash = '{original}' \
AND date_taken_source = 'manual'"
)),
0
);
}
#[actix_rt::test]
async fn photos_without_versions_is_unchanged() {
let fx = fx();