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:
1 parent
0e1fdd43e5
commit
51600f900d
3 files changed
+129
-2
No files matched your search
@@ -926,6 +926,29 @@ fn earliest_fs_time(response: &MetadataResponse) -> Option<i64> {
|
||||
}
|
||||
}
|
||||
|
||||
/// A manual date on a photo version (#191) is overwritten by the next
|
||||
/// metadata sync (`sync_version_metadata` re-copies the original's date), so
|
||||
/// the edit is redirected to the original, as tag writes are. Returns the
|
||||
/// `(library, path)` the edit applies to: the original's when `path` is a
|
||||
/// linked version with a live original, else the inputs unchanged.
|
||||
fn date_edit_target<'a>(
|
||||
app_state: &'a AppState,
|
||||
library: &'a libraries::Library,
|
||||
path: &str,
|
||||
) -> (&'a libraries::Library, String) {
|
||||
let original = app_state
|
||||
.version_dao
|
||||
.lock()
|
||||
.expect("Unable to lock VersionDao")
|
||||
.original_location_of(library.id, path)
|
||||
.ok()
|
||||
.flatten();
|
||||
match original {
|
||||
Some((lib_id, rel)) => (app_state.library_by_id(lib_id).unwrap_or(library), rel),
|
||||
None => (library, path.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
#[post("/image/exif/date")]
|
||||
#[tracing::instrument(name = "set_image_date", skip_all)]
|
||||
pub async fn set_image_date(
|
||||
@@ -949,6 +972,7 @@ pub async fn set_image_date(
|
||||
// Path normalization matches set_image_gps so a Windows-import client
|
||||
// doesn't end up with a backslash variant that misses the row.
|
||||
let normalized_path = body.path.replace('\\', "/");
|
||||
let (library, normalized_path) = date_edit_target(&app_state, library, &normalized_path);
|
||||
|
||||
// The user's display zone — the wall the UI sent is rendered in this
|
||||
// zone (ADR-0001, ticket #115). NULL / unparseable prefs fall back to
|
||||
@@ -1012,6 +1036,7 @@ pub async fn clear_image_date(
|
||||
};
|
||||
|
||||
let normalized_path = body.path.replace('\\', "/");
|
||||
let (library, normalized_path) = date_edit_target(&app_state, library, &normalized_path);
|
||||
|
||||
let updated = {
|
||||
let mut dao = exif_dao.lock().expect("Unable to lock ExifDao");
|
||||
|
||||
Reference in new issue
Block a user