diff --git a/crates/engine/src/activity.rs b/crates/engine/src/activity.rs index 147d20f3a58..61f2f093f9c 100644 --- a/crates/engine/src/activity.rs +++ b/crates/engine/src/activity.rs @@ -73,7 +73,7 @@ impl Unit { pub struct TaskInfo { pub id: u64, /// A stable id: `import`, `export`, `scan`, `previews`, `smartPreviews`, `lightroom`, `merge`, `download`, - /// `faces`, `denoise`, `findMissing`, `applePhotos`, `cache`, `focus`. + /// `faces`, `denoise`, `findMissing`, `applePhotos`, `cache`, `focus`, `saveMetadata`, `readMetadata`. pub kind: &'static str, /// English; the frontend translates it. pub label: String, diff --git a/crates/engine/src/cmd.rs b/crates/engine/src/cmd.rs index 9b8dc3dbd28..609fdbe308c 100644 --- a/crates/engine/src/cmd.rs +++ b/crates/engine/src/cmd.rs @@ -20,6 +20,7 @@ mod face_models; mod face_recognize; pub mod filters; mod focus; +pub mod folder_metadata; pub mod geocode; pub mod keywords; pub mod library; @@ -177,6 +178,7 @@ pub fn command_specs() -> &'static [CommandSpec] { v.extend(face_detect::specs()); v.extend(face_recognize::specs()); v.extend(focus::specs()); + v.extend(folder_metadata::specs()); v.extend(activity::specs()); v }) diff --git a/crates/engine/src/cmd/folder_metadata.rs b/crates/engine/src/cmd/folder_metadata.rs new file mode 100644 index 00000000000..d5b70a4792d --- /dev/null +++ b/crates/engine/src/cmd/folder_metadata.rs @@ -0,0 +1,357 @@ +//! Save Metadata to Files and Read Metadata from Files for a whole folder of the library +//! (`folder.saveMetadata`, `folder.readMetadata`): what `photo.saveMetadataToFile` and +//! `photo.readMetadataFromFile` do for the selection, for every library photo of one folder and +//! the folders inside it, with a row in the activity stack (kinds `saveMetadata` and +//! `readMetadata`, "n of N", the file in hand as detail, ✕ stops it). The Folders and Local +//! folder menus' Save/Read Metadata items will use it. +//! +//! - **Scope** is the Folders tree's: the library photos imported from the folder or any folder +//! inside it (`library.removeFolder`'s rule, `Filter::library_folder`, the path as given). Local-only +//! records seen while browsing are not library photos and are left alone, as are photos in +//! Recently Deleted and virtual copies (their settings live only in the library; a read would +//! put the master's file over the copy's own settings). +//! - **Work is done photo by photo** by a [`FolderMetadataJob`]: the session is needed for every +//! file (sidecar naming, the repair queues), so the job is paced rather than moved to another +//! thread, as the focus-point reader is. The commands run it in two ways. Plainly +//! (`{path}`), one call plans it, does every photo and ends it: for scripts, the CLI and MCP, +//! where nothing else runs meanwhile, so the row can't be stopped then. With `background: true` +//! the call only plans it and returns; a frontend calls `folder.metadataPump` every frame, which +//! does photos for a few milliseconds and ends the job after the last, so the window keeps +//! drawing, the row shows its count and its ✕ (or `activity.cancel`) stops the job at the next +//! pump (a stopped job nobody pumps is ended by the next folder command, a stopped read then +//! committing what it read as its own undo step). One job runs at a time; opening another +//! library drops it. The work never goes through the automatic sidecar writes: an explicit +//! save writes its files before it reports. +//! Which photos share a stem sidecar is worked out again whenever the catalog changed since the +//! last photo (never during a plain call), so a file imported while a paced job waits is +//! named as the photo commands would name it. +//! - **Cancel** is checked before each photo. A canceled save keeps the sidecars already +//! written. A canceled read commits what it has read so far as one undo step. Either way the +//! result has `cancelled: true`, and `done` of `total` says how far it got. +//! - **A file that can't be saved or read** (offline, missing, read-only, not XMP) lands in +//! `failed` with its photo id and the reason, and the rest go on. So does a photo that was +//! deleted, moved or edited while a paced job was between two pumps: a read never puts a +//! sidecar over an edit made after the file was read, and a save never writes a photo that has +//! left the folder. +//! - **A read** is one undo step ("Read Metadata from Files"), and never writes the sidecars it +//! has read, auto-write or not (`Session::skip_auto_write`, as `photo.readMetadataFromFile` +//! does, issue #934); [`FolderMetadataJob::finish`] must therefore run inside a command. + +use std::sync::Arc; +use std::time::Duration; + +use lightcraft_catalog::{Filter, Op, Photo, PhotoId, Sort, Source}; +use serde_json::{Value, json}; + +use super::{CommandSpec, always, bad, bool_or, cmd, str_param}; +use crate::activity::{Cancel, TaskGuard}; +use crate::sidecar::{SidecarNaming, StemOwners}; +use crate::{Result, Session}; + +/// What a job does with each photo's file. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Direction { + /// Write the photo's XMP sidecar. + Save, + /// Take the photo's sidecar (or embedded XMP) into the catalog. + Read, +} + +impl Direction { + fn command(self) -> &'static str { + match self { + Direction::Save => "folder.saveMetadata", + Direction::Read => "folder.readMetadata", + } + } +} + +/// A photo to do and the file it had when the job was planned (a photo removed, moved or relinked +/// meanwhile is reported in `failed`, not written under another file's name). +struct Item { + id: PhotoId, + path: String, +} + +/// What the job needs from the whole library, worked out when it is planned and again at the next +/// photo after the catalog changed (per photo it would be a pass over the catalog each). +enum Naming { + /// The owners of the stems the photos share with other files. + Save(StemOwners), + /// The sidecar naming of each item, in order. + Read(Vec), +} + +/// A photo read: its catalog entry as it was then, and what came of the file. The op is dropped +/// at [`FolderMetadataJob::finish`] when the photo is no longer that entry. +struct Read { + id: PhotoId, + photo: Arc, + op: Op, + from: String, +} + +/// A folder's metadata save or read in progress: planned without touching the disk, advanced one +/// photo per [`FolderMetadataJob::step`], ended by [`FolderMetadataJob::finish`]. Dropping it +/// ends its row in the activity stack and abandons what a read had gathered. +pub struct FolderMetadataJob { + direction: Direction, + items: Vec, + next: usize, + task: TaskGuard, + naming: Naming, + /// The catalog revision `naming` was worked out at. + revision: u64, + cancelled: bool, + written: Vec, + merged: Vec, + backups: Vec, + reads: Vec, + warnings: Vec, + failed: Vec, +} + +impl FolderMetadataJob { + /// The job for the library photos in `folder` and the folders inside it. No file is touched. + pub fn plan(s: &Session, direction: Direction, folder: &str) -> Result { + let c = direction.command(); + // as given, like every folder command: a folder named with a space at its edge is not its neighbor + if folder.trim().is_empty() || lightcraft_catalog::query::folder_key(folder).is_empty() { + return Err(bad(c, "`path` must be a folder from library.folders")); + } + let filter = Filter { library_folder: Some(folder.to_string()), ..Default::default() }; + let ids = s.catalog.query(&filter, &Sort::default()); + if ids.is_empty() { + return Err(bad(c, format!("{folder}: no photo in the library was imported from it"))); + } + let items: Vec = ids + .iter() + .filter_map(|id| { + let p = s.catalog.photo(*id)?; + match &p.source { + Source::File { path } if p.copy_of.is_none() => Some(Item { id: *id, path: path.clone() }), + _ => None, + } + }) + .collect(); + if items.is_empty() { + return Err(bad(c, format!("{folder}: its photos have no file of their own"))); + } + let ids: Vec = items.iter().map(|i| i.id).collect(); + let naming = match direction { + Direction::Save => Naming::Save(StemOwners::among(&s.catalog, &ids)), + Direction::Read => Naming::Read(s.sidecar_namings(&ids)), + }; + let (kind, label) = match direction { + Direction::Save => ("saveMetadata", "Saving metadata to files"), + Direction::Read => ("readMetadata", "Reading metadata from files"), + }; + let task = s.activity.start(kind, label, Cancel::Yes); + task.progress(0, items.len() as u64); + Ok(FolderMetadataJob { + direction, + items, + next: 0, + task, + naming, + revision: s.catalog.revision, + cancelled: false, + written: Vec::new(), + merged: Vec::new(), + backups: Vec::new(), + reads: Vec::new(), + warnings: Vec::new(), + failed: Vec::new(), + }) + } + + /// The photos the folder held when the job was planned. + pub fn total(&self) -> usize { + self.items.len() + } + + /// The photos done so far (failed ones included). + pub fn done(&self) -> usize { + self.next + } + + /// The row in the activity stack. + pub fn task_id(&self) -> u64 { + self.task.id() + } + + /// Does the next photo. Returns whether there is more to do: `false` once every photo is done + /// or the row's ✕ was pressed (checked before each photo, so the one in hand always finishes). + pub fn step(&mut self, s: &mut Session) -> bool { + if self.cancelled { + return false; + } + if self.task.is_cancelled() { + self.cancelled = true; + return false; + } + // a file imported or relinked since may now share a stem with these photos: name from the catalog as it is + if self.revision != s.catalog.revision { + let ids: Vec = self.items.iter().map(|i| i.id).collect(); + self.naming = match &self.naming { + Naming::Save(_) => Naming::Save(StemOwners::among(&s.catalog, &ids)), + Naming::Read(_) => Naming::Read(s.sidecar_namings(&ids)), + }; + self.revision = s.catalog.revision; + } + let Some(item) = self.items.get(self.next) else { return false }; + let id = item.id; + if let Some(name) = std::path::Path::new(&item.path).file_name() { + self.task.detail(&name.to_string_lossy()); + } + let in_place = s.catalog.photo(id).is_some_and(|p| !p.deleted && matches!(&p.source, Source::File { path } if *path == item.path)); + if !in_place { + self.failed.push(json!({"id": id.0, "error": "the photo was deleted, moved or relinked while the folder was being done"})); + } else { + match &self.naming { + Naming::Save(owners) => match s.save_sidecar_with(id, owners) { + Ok(r) => { + let path = r.path.display().to_string(); + if r.merged { + self.merged.push(path.clone()); + } + if let Some(b) = r.backup { + self.backups.push(json!({"path": path, "backup": b.display().to_string()})); + } + self.written.push(path); + } + Err(e) => self.failed.push(json!({"id": id.0, "error": e.to_string()})), + }, + Naming::Read(namings) => { + let naming = namings.get(self.next).copied().unwrap_or(s.xmp.naming); + let photo = s.catalog.photo(id).cloned(); + match (s.read_sidecar_op_named(id, naming), photo) { + (Ok(Some((op, from, mut warnings))), Some(photo)) => { + self.reads.push(Read { id, photo, op, from: from.display().to_string() }); + self.warnings.append(&mut warnings); + } + (Ok(_), None) | (Ok(None), _) => self.failed.push(json!({"id": id.0, "error": "no XMP sidecar or embedded XMP"})), + (Err(e), _) => self.failed.push(json!({"id": id.0, "error": e.to_string()})), + } + } + } + } + self.next = self.next.saturating_add(1); + self.task.progress(self.next as u64, self.items.len() as u64); + self.next < self.items.len() + } + + /// Ends the job: a read commits what it read as one undo step, except for a photo that was + /// edited, deleted or moved since its file was read (it goes to `failed`). The result is + /// `{total, done, cancelled, written, merged, backups, failed}` for a save and + /// `{total, done, cancelled, read, failed, warnings?}` for a read. + pub fn finish(mut self, s: &mut Session) -> Result { + let (total, done, cancelled) = (self.items.len(), self.next, self.cancelled); + let mut result = match self.direction { + Direction::Save => json!({"written": self.written, "merged": self.merged, "backups": self.backups, "failed": self.failed}), + Direction::Read => { + let mut ops = Vec::new(); + let mut read = Vec::new(); + for r in std::mem::take(&mut self.reads) { + if s.catalog.photo(r.id).is_some_and(|now| Arc::ptr_eq(now, &r.photo)) { + ops.push(r.op); + read.push(json!({"id": r.id.0, "from": r.from})); + } else { + self.failed.push(json!({"id": r.id.0, "error": "the photo changed while the folder was being read (an edit, or an update made in the background): read it again"})); + } + } + if !ops.is_empty() { + s.commit("Read Metadata from Files", Op::Batch { ops })?; + // the sidecars just read are not written back (see the module docs) + s.skip_auto_write = true; + } + let mut r = json!({"read": read, "failed": self.failed}); + if !self.warnings.is_empty() { + r["warnings"] = serde_json::to_value(&self.warnings).unwrap_or_default(); + } + r + } + }; + result["total"] = json!(total); + result["done"] = json!(done); + result["cancelled"] = json!(cancelled); + Ok(result) + } +} + +/// `folder.saveMetadata` / `folder.readMetadata`: plan, then either hand the job to the session +/// (`background`) or do it all now. +fn run(s: &mut Session, p: &Value, direction: Direction) -> Result { + let c = direction.command(); + let folder = str_param(p, "path").ok_or_else(|| bad(c, "missing `path`"))?; + // a waiting job whose row was stopped has nobody left to end it when no frontend pumps: end it here + if let Some(stopped) = s.folder_metadata.take_if(|j| j.task.is_cancelled()) { + stopped.finish(s)?; + } + if s.folder_metadata.is_some() { + return Err(bad(c, "a folder's metadata is already being saved or read: let it finish, or stop it in the activity stack")); + } + let mut job = FolderMetadataJob::plan(s, direction, folder)?; + if bool_or(p, "background", false) { + let total = job.total(); + s.folder_metadata = Some(job); + return Ok(json!({"started": true, "total": total})); + } + while job.step(s) {} + job.finish(s) +} + +/// `folder.metadataPump`: does photos of the background job for about `budgetMs`, and ends it when +/// the last is done or its row was stopped. +fn pump(s: &mut Session, p: &Value) -> Result { + let budget = Duration::from_millis(p.get("budgetMs").and_then(Value::as_u64).unwrap_or(10).clamp(0, 1000)); + let Some(mut job) = s.folder_metadata.take() else { return Ok(json!({"running": false})) }; + let began = web_time::Instant::now(); + // (the job is out of the session while it works, so a panic below drops it and its row) + let more = loop { + if !job.step(s) { + break false; + } + if began.elapsed() >= budget { + break true; + } + }; + if more { + let status = json!({"running": true, "done": job.done(), "total": job.total()}); + s.folder_metadata = Some(job); + return Ok(status); + } + Ok(json!({"running": false, "result": job.finish(s)?})) +} + +pub fn specs() -> Vec { + vec![ + cmd!( + "folder.saveMetadata", + "Save Metadata to Files", + [], + None, + "{path, background?: false} — as photo.saveMetadataToFile for every library photo imported from the folder or a folder inside it (not Local-only browse records, Recently Deleted or virtual copies), with a row in the activity stack (`saveMetadata`); a photo whose file can't be written lands in `failed` and the rest go on. Plain, it does every photo before it returns → {total, done, cancelled, written: [path], merged: [path], backups: [{path, backup}], failed: [{id, error}]}. With `background: true` it only plans the work → {started, total}; each `folder.metadataPump` call (the caller repeats it; the app doesn't yet) then does it a few milliseconds at a time, and the row's ✕ or `activity.cancel` stops it (the sidecars already written stay)", + always, + |s, p| run(s, p, Direction::Save) + ), + cmd!( + "folder.readMetadata", + "Read Metadata from Files", + [], + None, + "{path, background?: false} — as photo.readMetadataFromFile for every library photo imported from the folder or a folder inside it (not Local-only browse records, Recently Deleted or virtual copies), with a row in the activity stack (`readMetadata`): one undo step, never writes the sidecars it reads, even with auto-write on; a photo without a readable sidecar lands in `failed` and the rest go on, and so does one edited while a background read ran. Plain, it does every photo before it returns → {total, done, cancelled, read: [{id, from}], failed: [{id, error}], warnings?}. With `background: true` it only plans the work → {started, total}; `folder.metadataPump` then does it, and a stopped read commits what it had read", + always, + |s, p| run(s, p, Direction::Read) + ), + cmd!( + query "folder.metadataPump", + "Save or Read Folder Metadata in the Background", + [], + None, + "{budgetMs?: 10} → {running: false} when no background job is waiting, {running: true, done, total} while one is, or {running: false, result} with the job's result (as the plain command's) when it ended — cheap enough to call every frame: does photos for about `budgetMs` (0–1000; at least one photo is done) and ends the job after the last, or at the next call after its row was stopped", + always, + pump + ), + ] +} diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index acaa1807009..76a4ef3dbe2 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -273,6 +273,8 @@ pub struct Session { /// Set by a command whose change must not rewrite the photo's XMP sidecar even with auto-write on /// (a catalog-only edit of data the sidecar writer does not emit); consumed when the command ends. pub(crate) skip_auto_write: bool, + /// The folder metadata save or read waiting for `folder.metadataPump` ([`cmd::folder_metadata`]); dropped when another library opens. + pub(crate) folder_metadata: Option, /// The order of Reload from Disk runs, so an older one finishing late is dropped ([`cmd::reload`]). pub(crate) reload_tickets: cmd::reload::Tickets, /// Photos whose automatic XMP sidecar write failed (their folder offline, read-only or full), written again by @@ -471,6 +473,7 @@ impl Session { pending_sidecar_repairs: Vec::new(), interaction: None, skip_auto_write: false, + folder_metadata: None, reload_tickets: Default::default(), unsaved_sidecars: Default::default(), denoise: Default::default(), diff --git a/crates/engine/src/library.rs b/crates/engine/src/library.rs index a5071b4b358..f9f5bc483e6 100644 --- a/crates/engine/src/library.rs +++ b/crates/engine/src/library.rs @@ -461,7 +461,8 @@ impl Session { { log::error!("library: {e}"); } - // Photo ids belong to one library; denoise work must not carry into the next. + // Photo ids belong to one library; a folder's metadata job and denoise work must not carry into the next. + self.folder_metadata = None; self.denoise.library_changed(); self.media.denoise.clear(); // what was learned about the old library's faces is saved, and none of it carries over (photo ids are per library) diff --git a/crates/engine/src/sidecar.rs b/crates/engine/src/sidecar.rs index d13b9512571..f772845ec08 100644 --- a/crates/engine/src/sidecar.rs +++ b/crates/engine/src/sidecar.rs @@ -828,9 +828,19 @@ impl Session { /// Like [`Session::read_sidecar_op`], retaining transient diagnostics for the command report. pub fn read_sidecar_op_with_warnings(&self, id: PhotoId) -> Result)>> { + self.read_sidecar_op_named(id, self.sidecar_naming(id)) + } + + /// [`Session::read_sidecar_op_with_warnings`] with the sidecar naming already worked out ([`StemOwners::naming`]): a + /// folder of photos knows its owners once, instead of one pass over the catalog per photo. + pub(crate) fn read_sidecar_op_named( + &self, + id: PhotoId, + naming: SidecarNaming, + ) -> Result)>> { let p = self.catalog.photo(id).ok_or(lightcraft_catalog::CatalogError::NoPhoto(id))?; let Some(orig) = file_path(p) else { return Ok(None) }; - let Some((packet, from)) = read_packet(orig, p.kind, self.sidecar_naming(id)) else { return Ok(None) }; + let Some((packet, from)) = read_packet(orig, p.kind, naming) else { return Ok(None) }; let sc = parse_sidecar(&packet, crate::crs::Target::for_photo(p)).map_err(|e| EngineError::Other(format!("{}: {e}", from.display())))?; let mut warnings = sc.warnings.clone(); for warning in &mut warnings { diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index ae03859d21f..f13e677ba2d 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -19,6 +19,8 @@ mod face_tiles; mod filesystem_history; #[cfg(all(test, not(target_arch = "wasm32")))] mod focus_scan; +#[cfg(all(test, not(target_arch = "wasm32")))] +mod folder_metadata; mod folders; mod forget_local; mod history_cursor; diff --git a/crates/engine/src/tests/folder_metadata.rs b/crates/engine/src/tests/folder_metadata.rs new file mode 100644 index 00000000000..b51853e41e6 --- /dev/null +++ b/crates/engine/src/tests/folder_metadata.rs @@ -0,0 +1,497 @@ +//! Save Metadata to Files / Read Metadata from Files for a folder (`folder.saveMetadata`, +//! `folder.readMetadata`): scope, cancel, one undo step, failures that don't stop the rest, +//! hostile input. Procedural files in temp directories only. + +use std::path::{Path, PathBuf}; + +use lightcraft_catalog::{Op, Photo, PhotoId, Source}; +use serde_json::{Value, json}; + +use crate::Session; +use crate::cmd::folder_metadata::{Direction, FolderMetadataJob}; +use crate::tests_xmp::temp_dir; + +fn write_png(path: &Path, seed: u8) { + if let Some(dir) = path.parent() { + std::fs::create_dir_all(dir).unwrap(); + } + let (w, h) = (16usize, 12usize); + let data: Vec<[u8; 4]> = (0..w * h).map(|i| [(i % w * 9) as u8, (i / w * 12) as u8, seed, 255]).collect(); + let img = lightcraft_raster::Rgba8 { width: w, height: h, data }; + let bytes = lightcraft_codecs::encode_png(&lightcraft_codecs::EncodeImage::rgba8(&img), &lightcraft_codecs::EncodeMeta::default()).unwrap(); + std::fs::write(path, bytes).unwrap(); +} + +/// A library holding `a/one.png`, `a/two.png`, `a/sub/three.png` and `b/four.png`, auto-write off. +struct Fixture { + s: Session, + src: PathBuf, + lib: PathBuf, +} + +impl Fixture { + fn new(tag: &str) -> Fixture { + let src = temp_dir(&format!("fm-{tag}-src")); + let lib = temp_dir(&format!("fm-{tag}-lib")); + for (i, rel) in ["a/one.png", "a/two.png", "a/sub/three.png", "b/four.png"].iter().enumerate() { + write_png(&src.join(rel), i as u8 + 1); + } + let mut s = Session::new().with_fs(); + s.open_library(&lib, false).unwrap(); + s.execute("library.xmpPreferences", &json!({"autoWrite": false})).unwrap(); + let r = s.execute("library.import", &json!({"paths": [src.to_string_lossy()]})).unwrap(); + assert_eq!(r["imported"].as_array().unwrap().len(), 4, "{r}"); + Fixture { s, src, lib } + } + + fn id(&self, name: &str) -> PhotoId { + self.s.catalog.photos().find(|p| p.file_name == name).unwrap().id + } + + fn rating(&self, name: &str) -> u8 { + self.s.catalog.photo(self.id(name)).unwrap().rating + } + + fn rate_all(&mut self, rating: u8) { + let ids: Vec = self.s.catalog.photos().map(|p| p.id.0).collect(); + self.s.execute("photo.rate", &json!({"ids": ids, "rating": rating})).unwrap(); + } + + fn folder(&self, rel: &str) -> String { + self.src.join(rel).to_string_lossy().into_owned() + } + + fn sidecar(&self, rel: &str) -> PathBuf { + self.src.join(rel) + } +} + +impl Drop for Fixture { + fn drop(&mut self) { + let _ = std::fs::remove_dir_all(&self.src); + let _ = std::fs::remove_dir_all(&self.lib); + } +} + +fn count(v: &Value, key: &str) -> usize { + v[key].as_array().map_or(usize::MAX, Vec::len) +} + +#[test] +fn saving_a_folder_writes_its_photos_and_the_folders_inside_only() { + let mut f = Fixture::new("save-scope"); + f.rate_all(3); + let r = f.s.execute("folder.saveMetadata", &json!({"path": f.folder("a")})).unwrap(); + assert_eq!((r["total"].as_u64(), r["done"].as_u64(), r["cancelled"].as_bool()), (Some(3), Some(3), Some(false)), "{r}"); + assert_eq!((count(&r, "written"), count(&r, "failed")), (3, 0), "{r}"); + for rel in ["a/one.xmp", "a/two.xmp", "a/sub/three.xmp"] { + assert!(f.sidecar(rel).is_file(), "{rel}"); + } + assert!(!f.sidecar("b/four.xmp").exists(), "a photo outside the folder is untouched"); + // a folder beside it writes only its own + let r = f.s.execute("folder.saveMetadata", &json!({"path": f.folder("b")})).unwrap(); + assert_eq!(count(&r, "written"), 1, "{r}"); + assert!(f.sidecar("b/four.xmp").is_file()); + // and a subfolder alone leaves the folder around it as it is + std::fs::remove_file(f.sidecar("a/one.xmp")).unwrap(); + let r = f.s.execute("folder.saveMetadata", &json!({"path": f.folder("a/sub")})).unwrap(); + assert_eq!((r["total"].as_u64(), count(&r, "written")), (Some(1), 1), "{r}"); + assert!(!f.sidecar("a/one.xmp").exists(), "a/one.png is not in a/sub"); + // the row ends with the command + assert!(f.s.activity.list().is_empty()); +} + +#[test] +fn saving_leaves_local_browse_records_deleted_photos_and_virtual_copies_alone() { + let mut f = Fixture::new("save-kinds"); + // a Local-only record inside the folder: a file seen while browsing, never imported + write_png(&f.src.join("a/browsed.png"), 9); + let mut local = + Photo::new(PhotoId(900_001), Source::File { path: f.folder("a/browsed.png") }, "browsed.png", "PNG", 16, 12, "2026-10-25T00:00:00"); + local.local = true; + f.s.execute_fn("test.add", |s| s.apply_system(Op::AddPhoto { photo: Box::new(local) }).map(|()| Value::Null)).unwrap(); + // a deleted photo and a virtual copy + let (two, one) = (f.id("two.png"), f.id("one.png")); + f.s.execute("photo.delete", &json!({"ids": [two.0]})).unwrap(); + f.s.execute("photo.virtualCopy", &json!({"ids": [one.0]})).unwrap(); + let r = f.s.execute("folder.saveMetadata", &json!({"path": f.folder("a")})).unwrap(); + assert_eq!(r["total"], 2, "one.png and three.png: {r}"); + assert_eq!((count(&r, "written"), count(&r, "failed")), (2, 0), "{r}"); + assert!(f.sidecar("a/one.xmp").is_file() && f.sidecar("a/sub/three.xmp").is_file()); + assert!(!f.sidecar("a/browsed.xmp").exists(), "a Local-only record is not a library photo"); + assert!(!f.sidecar("a/two.xmp").exists(), "a deleted photo is not in the folder"); +} + +#[test] +fn a_missing_file_is_reported_and_the_rest_are_saved() { + let mut f = Fixture::new("save-missing"); + let two = f.id("two.png"); + std::fs::remove_file(f.src.join("a/two.png")).unwrap(); + let r = f.s.execute("folder.saveMetadata", &json!({"path": f.folder("a")})).unwrap(); + assert_eq!((count(&r, "written"), count(&r, "failed")), (2, 1), "{r}"); + assert_eq!(r["failed"][0]["id"], two.0, "{r}"); + assert!(r["failed"][0]["error"].as_str().unwrap().contains("two.png"), "{r}"); + assert_eq!(r["done"], 3, "{r}"); + assert!(f.sidecar("a/one.xmp").is_file() && f.sidecar("a/sub/three.xmp").is_file()); +} + +#[test] +fn a_save_merges_into_an_existing_sidecar_as_the_photo_command_does() { + let mut f = Fixture::new("save-merge"); + std::fs::write( + f.sidecar("a/one.xmp"), + "", + ) + .unwrap(); + let r = f.s.execute("folder.saveMetadata", &json!({"path": f.folder("a")})).unwrap(); + assert_eq!(count(&r, "merged"), 1, "{r}"); + let text = std::fs::read_to_string(f.sidecar("a/one.xmp")).unwrap(); + assert!(text.contains("foo:keep"), "another app's data is kept: {text}"); +} + +#[test] +fn cancelling_a_save_stops_between_photos_and_reports_what_was_done() { + let mut f = Fixture::new("save-cancel"); + let mut job = FolderMetadataJob::plan(&f.s, Direction::Save, &f.folder("a")).unwrap(); + assert_eq!((job.total(), job.done()), (3, 0)); + let rows = f.s.activity.list(); + assert_eq!((rows.len(), rows[0].kind, rows[0].total, rows[0].cancellable), (1, "saveMetadata", 3, true), "{rows:?}"); + assert!(job.step(&mut f.s), "more photos are left"); + assert_eq!(f.s.activity.list()[0].done, 1); + f.s.execute("activity.cancel", &json!({"id": job.task_id()})).unwrap(); + assert!(!job.step(&mut f.s), "no photo is started once cancelled"); + let r = job.finish(&mut f.s).unwrap(); + assert_eq!((r["total"].as_u64(), r["done"].as_u64(), r["cancelled"].as_bool()), (Some(3), Some(1), Some(true)), "{r}"); + assert_eq!(count(&r, "written"), 1, "the file in hand was finished: {r}"); + let written = ["a/one.xmp", "a/two.xmp", "a/sub/three.xmp"].iter().filter(|rel| f.sidecar(rel).exists()).count(); + assert_eq!(written, 1, "the sidecars written before the cancel stay, no others are written"); + assert!(f.s.activity.list().is_empty(), "the row ends with the job"); +} + +/// Save every sidecar with rating 3, then give every photo rating 1 in the catalog only (auto-write off). +fn saved_at_three(f: &mut Fixture) { + f.rate_all(3); + let ids: Vec = f.s.catalog.photos().map(|p| p.id.0).collect(); + let r = f.s.execute("photo.saveMetadataToFile", &json!({"ids": ids})).unwrap(); + assert_eq!(count(&r, "written"), 4, "{r}"); + f.rate_all(1); +} + +#[test] +fn reading_a_folder_is_one_undo_step_and_only_that_folder() { + let mut f = Fixture::new("read-scope"); + saved_at_three(&mut f); + let before = f.s.commits(); + let r = f.s.execute("folder.readMetadata", &json!({"path": f.folder("a")})).unwrap(); + assert_eq!((r["total"].as_u64(), r["cancelled"].as_bool()), (Some(3), Some(false)), "{r}"); + assert_eq!((count(&r, "read"), count(&r, "failed")), (3, 0), "{r}"); + assert_eq!(f.s.commits(), before + 1, "one commit for the whole folder"); + for n in ["one.png", "two.png", "three.png"] { + assert_eq!(f.rating(n), 3, "{n}"); + } + assert_eq!(f.rating("four.png"), 1, "a photo outside the folder is not read"); + f.s.execute("edit.undo", &json!({})).unwrap(); + for n in ["one.png", "two.png", "three.png", "four.png"] { + assert_eq!(f.rating(n), 1, "one undo restores {n}"); + } + assert!(f.s.activity.list().is_empty()); +} + +#[test] +fn reading_does_not_write_the_sidecars_it_reads_even_with_auto_write_on() { + let mut f = Fixture::new("read-noautowrite"); + saved_at_three(&mut f); + let bytes = |f: &Fixture| std::fs::read(f.sidecar("a/one.xmp")).unwrap(); + let before = bytes(&f); + f.s.execute("library.xmpPreferences", &json!({"autoWrite": true})).unwrap(); + f.s.execute("folder.readMetadata", &json!({"path": f.folder("a")})).unwrap(); + assert_eq!(f.rating("one.png"), 3); + assert_eq!(bytes(&f), before, "the sidecar is as it was"); + assert!(f.s.unsaved_sidecars() == 0); +} + +#[test] +fn a_photo_without_a_sidecar_is_reported_and_the_rest_are_read() { + let mut f = Fixture::new("read-missing"); + saved_at_three(&mut f); + std::fs::remove_file(f.sidecar("a/two.xmp")).unwrap(); + let two = f.id("two.png"); + let r = f.s.execute("folder.readMetadata", &json!({"path": f.folder("a")})).unwrap(); + assert_eq!((count(&r, "read"), count(&r, "failed")), (2, 1), "{r}"); + assert_eq!(r["failed"][0]["id"], two.0, "{r}"); + assert_eq!((f.rating("one.png"), f.rating("two.png"), f.rating("three.png")), (3, 1, 3)); +} + +#[test] +fn an_unreadable_sidecar_is_reported_and_the_rest_are_read() { + let mut f = Fixture::new("read-bad"); + saved_at_three(&mut f); + std::fs::write(f.sidecar("a/one.xmp"), [0xff, 0xfe, 0x00, 0x9f]).unwrap(); + let r = f.s.execute("folder.readMetadata", &json!({"path": f.folder("a")})).unwrap(); + assert_eq!((count(&r, "read"), count(&r, "failed")), (2, 1), "{r}"); + assert_eq!((f.rating("one.png"), f.rating("two.png")), (1, 3)); +} + +#[test] +fn cancelling_a_read_commits_what_was_read_as_one_undo_step() { + let mut f = Fixture::new("read-cancel"); + saved_at_three(&mut f); + let before = f.s.commits(); + let mut job = FolderMetadataJob::plan(&f.s, Direction::Read, &f.folder("a")).unwrap(); + assert_eq!(f.s.activity.list()[0].kind, "readMetadata"); + assert!(job.step(&mut f.s)); + assert!(job.step(&mut f.s)); + f.s.execute("activity.cancel", &json!({"all": true})).unwrap(); + assert!(!job.step(&mut f.s)); + let r = f.s.execute_fn("test.finish", |s| job.finish(s)).unwrap(); + assert_eq!((r["total"].as_u64(), r["done"].as_u64(), r["cancelled"].as_bool()), (Some(3), Some(2), Some(true)), "{r}"); + assert_eq!(count(&r, "read"), 2, "{r}"); + assert_eq!(f.s.commits(), before + 1); + let read: usize = ["one.png", "two.png", "three.png"].iter().filter(|n| f.rating(n) == 3).count(); + assert_eq!(read, 2, "what was read is kept, the rest is not read"); + f.s.execute("edit.undo", &json!({})).unwrap(); + assert!(["one.png", "two.png", "three.png"].iter().all(|n| f.rating(n) == 1), "one undo step takes it back"); +} + +#[test] +fn a_photo_relinked_while_the_job_runs_is_not_written() { + let mut f = Fixture::new("relinked"); + let mut job = FolderMetadataJob::plan(&f.s, Direction::Save, &f.folder("a")).unwrap(); + let ids: Vec = ["one.png", "two.png", "three.png"].iter().map(|n| f.id(n)).collect(); + f.s.execute("photo.delete", &json!({"ids": ids.iter().map(|i| i.0).collect::>()})).unwrap(); + f.s.execute("edit.undo", &json!({})).unwrap(); + f.s.execute_fn("test.relink", |s| { + for id in &ids { + let path = s.catalog.photo(*id).map(|p| p.file_name.clone()).unwrap_or_default(); + s.apply_system(Op::Relink { id: *id, file_name: path.clone(), source: Source::File { path: format!("/nowhere/{path}") }, format: None })?; + } + Ok(Value::Null) + }) + .unwrap(); + while job.step(&mut f.s) {} + let r = job.finish(&mut f.s).unwrap(); + assert_eq!((count(&r, "written"), count(&r, "failed")), (0, 3), "{r}"); + assert!(!f.sidecar("a/one.xmp").exists()); +} + +#[test] +fn hostile_input_is_an_error_never_a_panic_or_a_write() { + let mut f = Fixture::new("hostile"); + let nowhere = f.src.join("nowhere").to_string_lossy().into_owned(); + let empty = f.src.join("empty"); + std::fs::create_dir_all(&empty).unwrap(); + let empty = empty.to_string_lossy().into_owned(); + let cases = [ + json!({}), + json!({"path": null}), + json!({"path": 5}), + json!({"path": ["a"]}), + json!({"path": ""}), + json!({"path": " "}), + json!({"path": "relative/dir"}), + json!({"path": "../../.."}), + json!({"path": "\u{0}"}), + json!({"path": nowhere}), + json!({"path": empty}), + json!({"path": f.folder("a/one.png")}), + json!({"path": format!("{}/a/../nowhere", f.src.display()), "ids": "x"}), + ]; + for id in ["folder.saveMetadata", "folder.readMetadata"] { + for case in &cases { + let r = f.s.execute(id, case); + assert!(r.is_err() || r.as_ref().is_ok_and(|v| v["total"].as_u64().is_some()), "{id} {case}: {r:?}"); + } + } + assert!(!f.sidecar("a/one.xmp").exists() && !f.sidecar("b/four.xmp").exists(), "nothing was written"); + assert!(f.s.activity.list().is_empty(), "no row is left behind"); + assert!(f.s.execute("folder.saveMetadata", &json!({"path": empty})).is_err()); + // and a good call still works after them + assert_eq!(f.s.execute("folder.saveMetadata", &json!({"path": f.folder("b")})).unwrap()["total"], 1); +} + +#[cfg(unix)] // Windows drops a trailing space from a folder name +#[test] +fn a_folder_named_with_a_space_at_its_edge_is_not_its_neighbor() { + let src = temp_dir("fm-space-src"); + let lib = temp_dir("fm-space-lib"); + write_png(&src.join("shoot /a.png"), 1); + write_png(&src.join("shoot/b.png"), 2); + let mut s = Session::new().with_fs(); + s.open_library(&lib, false).unwrap(); + s.execute("library.xmpPreferences", &json!({"autoWrite": false})).unwrap(); + s.execute("library.import", &json!({"paths": [src.to_string_lossy()]})).unwrap(); + let r = s.execute("folder.saveMetadata", &json!({"path": format!("{}/shoot ", src.display())})).unwrap(); + assert_eq!(r["total"], 1, "{r}"); + assert!(src.join("shoot /a.xmp").is_file(), "the folder with the space is the one written"); + assert!(!src.join("shoot/b.xmp").exists(), "its neighbor is not"); + let _ = std::fs::remove_dir_all(&src); + let _ = std::fs::remove_dir_all(&lib); +} + +/// Pump until the job ends (at most `max` times); returns the pump's last reply. +fn pump_until_done(f: &mut Fixture, max: usize) -> Value { + for _ in 0..max { + let r = f.s.execute("folder.metadataPump", &json!({"budgetMs": 1})).unwrap(); + if r["running"] == false { + return r; + } + } + panic!("the job did not end in {max} pumps"); +} + +#[test] +fn a_background_save_is_done_by_the_pump_and_shows_its_row() { + let mut f = Fixture::new("bg-save"); + assert_eq!(f.s.execute("folder.metadataPump", &json!({})).unwrap(), json!({"running": false}), "no job: nothing to do"); + let r = f.s.execute("folder.saveMetadata", &json!({"path": f.folder("a"), "background": true})).unwrap(); + assert_eq!(r, json!({"started": true, "total": 3})); + assert!(!f.sidecar("a/one.xmp").exists(), "starting writes nothing"); + let rows = f.s.activity.list(); + assert_eq!((rows.len(), rows[0].kind, rows[0].done, rows[0].total), (1, "saveMetadata", 0, 3), "{rows:?}"); + // a second one is refused while the first is waiting, plain or not + assert!(f.s.execute("folder.saveMetadata", &json!({"path": f.folder("b")})).is_err()); + assert!(f.s.execute("folder.readMetadata", &json!({"path": f.folder("b"), "background": true})).is_err()); + let r = pump_until_done(&mut f, 100); + assert_eq!((r["result"]["total"].as_u64(), count(&r["result"], "written"), r["result"]["cancelled"].as_bool()), (Some(3), 3, Some(false)), "{r}"); + assert!(f.sidecar("a/sub/three.xmp").is_file() && !f.sidecar("b/four.xmp").exists()); + assert!(f.s.activity.list().is_empty(), "the row ends with the job"); + assert_eq!(f.s.execute("folder.metadataPump", &json!({})).unwrap(), json!({"running": false})); + // and the next one starts + f.s.execute("folder.saveMetadata", &json!({"path": f.folder("b"), "background": true})).unwrap(); +} + +#[test] +fn stopping_a_background_read_between_pumps_commits_what_was_read_once() { + let mut f = Fixture::new("bg-read-cancel"); + saved_at_three(&mut f); + let before = f.s.commits(); + f.s.execute("folder.readMetadata", &json!({"path": f.folder("a"), "background": true})).unwrap(); + // a pump with a zero budget still does one photo + let r = f.s.execute("folder.metadataPump", &json!({"budgetMs": 0})).unwrap(); + assert_eq!((r["running"].as_bool(), r["done"].as_u64(), r["total"].as_u64()), (Some(true), Some(1), Some(3)), "{r}"); + let row = f.s.activity.list(); + assert_eq!((row[0].kind, row[0].done), ("readMetadata", 1)); + f.s.execute("activity.cancel", &json!({"id": row[0].id})).unwrap(); + let r = f.s.execute("folder.metadataPump", &json!({})).unwrap(); + assert_eq!((r["running"].as_bool(), r["result"]["cancelled"].as_bool(), r["result"]["done"].as_u64()), (Some(false), Some(true), Some(1)), "{r}"); + assert_eq!(count(&r["result"], "read"), 1, "{r}"); + assert_eq!(f.s.commits(), before + 1, "one undo step"); + assert_eq!(["one.png", "two.png", "three.png"].iter().filter(|n| f.rating(n) == 3).count(), 1); + assert!(f.s.activity.list().is_empty()); + f.s.execute("edit.undo", &json!({})).unwrap(); + assert!(["one.png", "two.png", "three.png"].iter().all(|n| f.rating(n) == 1)); +} + +#[test] +fn a_photo_edited_while_a_background_read_waits_keeps_its_edit() { + let mut f = Fixture::new("bg-read-edit"); + saved_at_three(&mut f); + f.s.execute("folder.readMetadata", &json!({"path": f.folder("a"), "background": true})).unwrap(); + f.s.execute("folder.metadataPump", &json!({"budgetMs": 0})).unwrap(); + let r = f.s.execute("folder.metadataPump", &json!({"budgetMs": 0})).unwrap(); + assert_eq!((r["running"].as_bool(), r["done"].as_u64()), (Some(true), Some(2)), "two photos are read, nothing is committed yet: {r}"); + // every photo is edited before the job ends: the two already read must keep the edit + let ids: Vec = ["one.png", "two.png", "three.png"].iter().map(|n| f.id(n).0).collect(); + f.s.execute("photo.rate", &json!({"ids": ids, "rating": 5})).unwrap(); + let r = pump_until_done(&mut f, 10); + let done = &r["result"]; + assert_eq!((done["total"].as_u64(), count(done, "read"), count(done, "failed")), (Some(3), 1, 2), "{r}"); + assert!(done["failed"][0]["error"].as_str().unwrap().contains("changed"), "{r}"); + let ratings: Vec = ["one.png", "two.png", "three.png"].iter().map(|n| f.rating(n)).collect(); + assert_eq!(ratings.iter().filter(|r| **r == 5).count(), 2, "the edit stays on the two photos read before it: {ratings:?}"); + assert_eq!(ratings.iter().filter(|r| **r == 3).count(), 1, "the photo read after the edit takes its file: {ratings:?}"); +} + +#[test] +fn a_photo_deleted_while_a_background_save_waits_is_not_written() { + let mut f = Fixture::new("bg-save-deleted"); + f.s.execute("folder.saveMetadata", &json!({"path": f.folder("a"), "background": true})).unwrap(); + let ids: Vec<(String, PhotoId)> = ["one.png", "two.png", "three.png"].iter().map(|n| (n.to_string(), f.id(n))).collect(); + for (_, id) in &ids { + f.s.execute("photo.delete", &json!({"ids": [id.0]})).unwrap(); + } + let r = pump_until_done(&mut f, 10); + assert_eq!((count(&r["result"], "written"), count(&r["result"], "failed")), (0, 3), "{r}"); + assert!(!f.sidecar("a/one.xmp").exists()); +} + +#[test] +fn opening_another_library_drops_a_waiting_job() { + let mut f = Fixture::new("bg-switch"); + f.s.execute("folder.saveMetadata", &json!({"path": f.folder("a"), "background": true})).unwrap(); + let other = temp_dir("fm-switch-other"); + f.s.open_library(&other, false).unwrap(); + assert!(f.s.activity.list().is_empty(), "its row ended"); + assert_eq!(f.s.execute("folder.metadataPump", &json!({})).unwrap(), json!({"running": false})); + assert!(!f.sidecar("a/one.xmp").exists()); + let _ = std::fs::remove_dir_all(&other); +} + +#[test] +fn a_read_names_each_photos_sidecar_as_the_photo_command_does() { + // a raw-less stem shared by a PNG and a JPG: the first by file name owns `x.xmp`, the other `x.jpg.xmp` + let src = temp_dir("fm-stem-src"); + let lib = temp_dir("fm-stem-lib"); + write_png(&src.join("d/x.png"), 1); + write_png(&src.join("d/x.tif"), 2); + let mut s = Session::new().with_fs(); + s.open_library(&lib, false).unwrap(); + s.execute("library.xmpPreferences", &json!({"autoWrite": false})).unwrap(); + s.execute("library.import", &json!({"paths": [src.to_string_lossy()]})).unwrap(); + let ids: Vec = s.catalog.photos().map(|p| p.id.0).collect(); + s.execute("photo.rate", &json!({"ids": ids, "rating": 2})).unwrap(); + s.execute("folder.saveMetadata", &json!({"path": src.join("d").to_string_lossy()})).unwrap(); + let by_photo = s.execute("photo.readMetadataFromFile", &json!({"ids": ids})).unwrap(); + let by_folder = s.execute("folder.readMetadata", &json!({"path": src.join("d").to_string_lossy()})).unwrap(); + let mut a: Vec = by_photo["read"].as_array().unwrap().iter().map(|r| format!("{}={}", r["id"], r["from"])).collect(); + let mut b: Vec = by_folder["read"].as_array().unwrap().iter().map(|r| format!("{}={}", r["id"], r["from"])).collect(); + a.sort(); + b.sort(); + assert_eq!(a.len(), 2, "{by_photo}"); + assert_eq!(a, b, "the same sidecar for each photo"); + let _ = std::fs::remove_dir_all(&src); + let _ = std::fs::remove_dir_all(&lib); +} + +#[test] +fn a_stopped_background_job_nobody_pumps_does_not_block_the_next_one() { + let mut f = Fixture::new("bg-stopped"); + saved_at_three(&mut f); + f.s.execute("folder.readMetadata", &json!({"path": f.folder("a"), "background": true})).unwrap(); + f.s.execute("folder.metadataPump", &json!({"budgetMs": 0})).unwrap(); + let before = f.s.commits(); + f.s.execute("activity.cancel", &json!({"all": true})).unwrap(); + // no pump follows: the next folder job ends the stopped one, which commits the one photo it read + let r = f.s.execute("folder.saveMetadata", &json!({"path": f.folder("b")})).unwrap(); + assert_eq!((r["total"].as_u64(), count(&r, "written")), (Some(1), 1), "{r}"); + assert_eq!(f.s.commits(), before + 1, "the stopped read kept what it had read"); + assert_eq!(["one.png", "two.png", "three.png"].iter().filter(|n| f.rating(n) == 3).count(), 1); + assert!(f.s.activity.list().is_empty()); + // a job that was not stopped still blocks + f.s.execute("folder.saveMetadata", &json!({"path": f.folder("b"), "background": true})).unwrap(); + assert!(f.s.execute("folder.saveMetadata", &json!({"path": f.folder("a")})).is_err()); +} + +#[test] +fn a_file_imported_while_a_background_save_waits_is_named_as_the_photo_command_would() { + let src = temp_dir("fm-stem-late-src"); + let lib = temp_dir("fm-stem-late-lib"); + write_png(&src.join("d/x.tif"), 1); + write_png(&src.join("other/x.png"), 2); + let mut s = Session::new().with_fs(); + s.open_library(&lib, false).unwrap(); + s.execute("library.xmpPreferences", &json!({"autoWrite": false})).unwrap(); + s.execute("library.import", &json!({"paths": [src.join("d").to_string_lossy()]})).unwrap(); + s.execute("folder.saveMetadata", &json!({"path": src.join("d").to_string_lossy(), "background": true})).unwrap(); + // x.png joins d/ before the first pump: it sorts before x.tif, so it now owns the stem sidecar x.xmp + std::fs::copy(src.join("other/x.png"), src.join("d/x.png")).unwrap(); + s.execute("library.import", &json!({"paths": [src.join("d/x.png").to_string_lossy()]})).unwrap(); + let r = s.execute("folder.metadataPump", &json!({})).unwrap(); + assert_eq!(r["result"]["total"], 1, "{r}"); + let id = s.catalog.photos().find(|p| p.file_name == "x.tif").unwrap().id; + let by_photo = s.execute("photo.saveMetadataToFile", &json!({"ids": [id.0]})).unwrap(); + assert_eq!(r["result"]["written"], by_photo["written"], "the same sidecar path as the photo command: {r} vs {by_photo}"); + assert!(!src.join("d/x.xmp").exists(), "the tif no longer takes the stem sidecar the png owns"); + let _ = std::fs::remove_dir_all(&src); + let _ = std::fs::remove_dir_all(&lib); +} diff --git a/crates/ui-egui/locales/cs.json b/crates/ui-egui/locales/cs.json index 52ca94a524d..9af824ef1af 100644 --- a/crates/ui-egui/locales/cs.json +++ b/crates/ui-egui/locales/cs.json @@ -1470,6 +1470,11 @@ "Raw photos": "Fotografie RAW", "Raw photos as DNG, with the edits embedded. Size, color and output options don't apply.": "Fotografie RAW jako DNG s vloženými úpravami. Volby velikosti, barev a výstupu se nepoužijí.", "Read Metadata from File": "Načíst metadata ze souboru", + "Saving metadata to files": "Ukládání metadat do souborů", + "Reading metadata from files": "Načítání metadat ze souborů", + "Save Metadata to Files": "Uložit metadata do souborů", + "Read Metadata from Files": "Načíst metadata ze souborů", + "Save or Read Folder Metadata in the Background": "Uložit nebo načíst metadata složky na pozadí", "Read metadata updates from XMP sidecars": "Načíst změny metadat z přidružených souborů XMP", "Read mode": "Režim čtení", "Read the SAM License": "Přečíst licenci SAM", diff --git a/crates/ui-egui/locales/de.json b/crates/ui-egui/locales/de.json index e2205db782f..e40ddc91191 100644 --- a/crates/ui-egui/locales/de.json +++ b/crates/ui-egui/locales/de.json @@ -1174,6 +1174,11 @@ "Raw photos": "RAW-Fotos", "Raw photos as DNG, with the edits embedded. Size, color and output options don't apply.": "RAW-Fotos als DNG mit eingebetteten Bearbeitungen. Größen-, Farb- und Ausgabeoptionen gelten nicht.", "Read Metadata from File": "Metadaten aus Datei lesen", + "Saving metadata to files": "Metadaten werden in Dateien gespeichert", + "Reading metadata from files": "Metadaten werden aus Dateien gelesen", + "Save Metadata to Files": "Metadaten in Dateien speichern", + "Read Metadata from Files": "Metadaten aus Dateien lesen", + "Save or Read Folder Metadata in the Background": "Metadaten eines Ordners im Hintergrund speichern oder lesen", "Read mode": "Lesemodus", "Read the SAM License": "SAM-Lizenz lesen", "Reading": "Wird gelesen", diff --git a/crates/ui-egui/locales/es.json b/crates/ui-egui/locales/es.json index 888af077ff2..c4df761bc25 100644 --- a/crates/ui-egui/locales/es.json +++ b/crates/ui-egui/locales/es.json @@ -1178,6 +1178,11 @@ "Raw photos": "Fotos RAW", "Raw photos as DNG, with the edits embedded. Size, color and output options don't apply.": "Fotos RAW como DNG, con las ediciones incrustadas. Las opciones de tamaño, color y salida no se aplican.", "Read Metadata from File": "Leer metadatos del archivo", + "Saving metadata to files": "Guardando metadatos en los archivos", + "Reading metadata from files": "Leyendo metadatos de los archivos", + "Save Metadata to Files": "Guardar metadatos en los archivos", + "Read Metadata from Files": "Leer metadatos de los archivos", + "Save or Read Folder Metadata in the Background": "Guardar o leer los metadatos de una carpeta en segundo plano", "Read mode": "Modo de lectura", "Read the SAM License": "Leer la licencia de SAM", "Reading": "Leyendo", diff --git a/crates/ui-egui/locales/fi.json b/crates/ui-egui/locales/fi.json index e0a8c622a36..f1ea2c6f9d9 100644 --- a/crates/ui-egui/locales/fi.json +++ b/crates/ui-egui/locales/fi.json @@ -1535,6 +1535,11 @@ "Raw photos as DNG, with the edits embedded. Size, color and output options don't apply.": "Raw-kuvat DNG:nä, muokkaukset upotettuina. Koko-, väri- ja tulosteasetukset eivät päde.", "Read Focus Points": "Lue tarkennuspisteet", "Read Metadata from File": "Lue metatiedot tiedostosta", + "Saving metadata to files": "Tallennetaan metatietoja tiedostoihin", + "Reading metadata from files": "Luetaan metatietoja tiedostoista", + "Save Metadata to Files": "Tallenna metatiedot tiedostoihin", + "Read Metadata from Files": "Lue metatiedot tiedostoista", + "Save or Read Folder Metadata in the Background": "Tallenna tai lue kansion metatiedot taustalla", "Read metadata updates from XMP sidecars": "Lue metatietopäivitykset XMP-sivutiedostoista", "Read mode": "Lukutila", "Read the SAM License": "Lue SAM-lisenssi", diff --git a/crates/ui-egui/locales/fr.json b/crates/ui-egui/locales/fr.json index 3278d6ccda6..ea7210a04be 100644 --- a/crates/ui-egui/locales/fr.json +++ b/crates/ui-egui/locales/fr.json @@ -1120,6 +1120,11 @@ "Raw photos": "Photos RAW", "Raw photos as DNG, with the edits embedded. Size, color and output options don't apply.": "Photos RAW au format DNG, avec les retouches intégrées. Les options de taille, de couleur et de sortie ne s'appliquent pas.", "Read Metadata from File": "Lire les métadonnées du fichier", + "Saving metadata to files": "Enregistrement des métadonnées dans les fichiers", + "Reading metadata from files": "Lecture des métadonnées des fichiers", + "Save Metadata to Files": "Enregistrer les métadonnées dans les fichiers", + "Read Metadata from Files": "Lire les métadonnées des fichiers", + "Save or Read Folder Metadata in the Background": "Enregistrer ou lire les métadonnées d'un dossier en arrière-plan", "Read mode": "Mode lecture", "Read the SAM License": "Lire la licence SAM", "Reading": "Lecture en cours", diff --git a/crates/ui-egui/locales/id.json b/crates/ui-egui/locales/id.json index 0d6da9b8fb8..f16522e2367 100644 --- a/crates/ui-egui/locales/id.json +++ b/crates/ui-egui/locales/id.json @@ -1522,6 +1522,11 @@ "Read Focus Points": "Baca titik fokus", "Read Focus Points in the Background": "Baca titik fokus di latar belakang", "Read Metadata from File": "Baca metadata dari file", + "Saving metadata to files": "Menyimpan metadata ke file", + "Reading metadata from files": "Membaca metadata dari file", + "Save Metadata to Files": "Simpan metadata ke file", + "Read Metadata from Files": "Baca metadata dari file", + "Save or Read Folder Metadata in the Background": "Simpan atau baca metadata folder di latar belakang", "Read metadata updates from XMP sidecars": "Baca pembaruan metadata dari file sidecar XMP", "Read mode": "Mode baca", "Read the SAM License": "Baca lisensi SAM", diff --git a/crates/ui-egui/locales/it.json b/crates/ui-egui/locales/it.json index e159fd47d15..40552aa9b00 100644 --- a/crates/ui-egui/locales/it.json +++ b/crates/ui-egui/locales/it.json @@ -1129,6 +1129,11 @@ "Raw photos": "Foto raw", "Raw photos as DNG, with the edits embedded. Size, color and output options don't apply.": "Le foto raw come DNG, con le modifiche incorporate. Le opzioni di dimensione, colore e uscita non si applicano.", "Read Metadata from File": "Leggi i metadati dal file", + "Saving metadata to files": "Salvataggio dei metadati nei file", + "Reading metadata from files": "Lettura dei metadati dai file", + "Save Metadata to Files": "Salva i metadati nei file", + "Read Metadata from Files": "Leggi i metadati dai file", + "Save or Read Folder Metadata in the Background": "Salva o leggi i metadati di una cartella in background", "Read mode": "Modalità lettura", "Read the SAM License": "Leggi la licenza SAM", "Reading": "Lettura", diff --git a/crates/ui-egui/locales/ja.json b/crates/ui-egui/locales/ja.json index e1834555bd7..34d2e93570f 100644 --- a/crates/ui-egui/locales/ja.json +++ b/crates/ui-egui/locales/ja.json @@ -1107,6 +1107,11 @@ "Raw photos": "RAW写真", "Raw photos as DNG, with the edits embedded. Size, color and output options don't apply.": "編集情報を含むDNGとしてRAW写真を書き出します。サイズ・色・出力の設定は適用されません", "Read Metadata from File": "ファイルからメタデータを読み込む", + "Saving metadata to files": "メタデータをファイルに保存中", + "Reading metadata from files": "ファイルからメタデータを読み込み中", + "Save Metadata to Files": "メタデータをファイルに保存", + "Read Metadata from Files": "ファイルからメタデータを読み込む", + "Save or Read Folder Metadata in the Background": "フォルダのメタデータをバックグラウンドで保存または読み込む", "Reading": "読み込み中", "Reading folder…": "フォルダを読み込み中…", "Recently Added": "最近追加した写真", diff --git a/crates/ui-egui/locales/ka.json b/crates/ui-egui/locales/ka.json index 32c40770018..8d82fd073c1 100644 --- a/crates/ui-egui/locales/ka.json +++ b/crates/ui-egui/locales/ka.json @@ -1613,6 +1613,11 @@ "Raws from the 52 camera models whose colour matrices LightCraft has measured (Sony ILCE-7M3, ILCE-7M4, ILCE-7RM3,": "52 კამერის მოდელის RAW-ები, რომელთა ფერთა მატრიცებიც LightCraft-მა გაზომა (Sony ILCE-7M3, ILCE-7M4, ILCE-7RM3,", "Raws from the Pentax KP, KF, K-3 Mark III (and Monochrome), K-70, K-1, K-1 Mark II, K-S1, K-S2 and 645Z no longer": "Pentax KP, KF, K-3 Mark III (და Monochrome), K-70, K-1, K-1 Mark II, K-S1, K-S2 და 645Z კამერების RAW ფაილები აღარ", "Read Metadata from File": "მეტამონაცემების წაკითხვა ფაილიდან", + "Saving metadata to files": "მეტამონაცემების ფაილებში შენახვა", + "Reading metadata from files": "მეტამონაცემების წაკითხვა ფაილებიდან", + "Save Metadata to Files": "მეტამონაცემების ფაილებში შენახვა", + "Read Metadata from Files": "მეტამონაცემების წაკითხვა ფაილებიდან", + "Save or Read Folder Metadata in the Background": "საქაღალდის მეტამონაცემების შენახვა ან წაკითხვა ფონურად", "Read metadata updates from XMP sidecars": "მეტამონაცემების განახლებების წაკითხვა XMP თანმხლები ფაილებიდან", "Read mode": "კითხვის რეჟიმი", "Read the SAM License": "SAM-ის ლიცენზიის წაკითხვა", diff --git a/crates/ui-egui/locales/pl.json b/crates/ui-egui/locales/pl.json index adac22e62ad..e7523a282e7 100644 --- a/crates/ui-egui/locales/pl.json +++ b/crates/ui-egui/locales/pl.json @@ -1091,6 +1091,11 @@ "Raw photos": "Zdjęcia RAW", "Raw photos as DNG, with the edits embedded. Size, color and output options don't apply.": "Zdjęcia RAW jako DNG z osadzonymi zmianami. Opcje rozmiaru, koloru i wyjścia nie mają zastosowania.", "Read Metadata from File": "Wczytaj metadane z pliku", + "Saving metadata to files": "Zapisywanie metadanych do plików", + "Reading metadata from files": "Wczytywanie metadanych z plików", + "Save Metadata to Files": "Zapisz metadane do plików", + "Read Metadata from Files": "Wczytaj metadane z plików", + "Save or Read Folder Metadata in the Background": "Zapisz lub wczytaj metadane folderu w tle", "Read mode": "Tryb odczytu", "Read the SAM License": "Przeczytaj licencję SAM", "Reading": "Wczytywanie", diff --git a/crates/ui-egui/locales/pt-br.json b/crates/ui-egui/locales/pt-br.json index e84fb7615b7..c939d2f332a 100644 --- a/crates/ui-egui/locales/pt-br.json +++ b/crates/ui-egui/locales/pt-br.json @@ -1138,6 +1138,11 @@ "Raw photos": "Fotos RAW", "Raw photos as DNG, with the edits embedded. Size, color and output options don't apply.": "Fotos RAW como DNG, com as edições incorporadas. As opções de tamanho, cor e saída não se aplicam.", "Read Metadata from File": "Ler metadados do arquivo", + "Saving metadata to files": "Salvando metadados nos arquivos", + "Reading metadata from files": "Lendo metadados dos arquivos", + "Save Metadata to Files": "Salvar metadados nos arquivos", + "Read Metadata from Files": "Ler metadados dos arquivos", + "Save or Read Folder Metadata in the Background": "Salvar ou ler os metadados de uma pasta em segundo plano", "Read mode": "Modo de leitura", "Read the SAM License": "Ler a licença do SAM", "Reading": "Lendo", diff --git a/crates/ui-egui/locales/ru.json b/crates/ui-egui/locales/ru.json index 306804df045..68e43a86dbc 100644 --- a/crates/ui-egui/locales/ru.json +++ b/crates/ui-egui/locales/ru.json @@ -951,6 +951,11 @@ "Raw photos": "RAW-фото", "Raw photos as DNG, with the edits embedded. Size, color and output options don't apply.": "RAW-фото как DNG со встроенными правками. Параметры размера, цвета и вывода не применяются.", "Read Metadata from File": "Прочитать метаданные из файла", + "Saving metadata to files": "Сохранение метаданных в файлы", + "Reading metadata from files": "Чтение метаданных из файлов", + "Save Metadata to Files": "Сохранить метаданные в файлы", + "Read Metadata from Files": "Прочитать метаданные из файлов", + "Save or Read Folder Metadata in the Background": "Сохранить или прочитать метаданные папки в фоне", "Read mode": "Режим чтения", "Read the SAM License": "Прочитать лицензию SAM", "Reading": "Чтение", diff --git a/crates/ui-egui/locales/sv.json b/crates/ui-egui/locales/sv.json index 66e69b7ba5d..dc0d12fa2e1 100644 --- a/crates/ui-egui/locales/sv.json +++ b/crates/ui-egui/locales/sv.json @@ -1676,6 +1676,11 @@ "Raw photos as DNG, with the edits embedded. Size, color and output options don't apply.": "Raw-foton som DNG, med redigeringarna inbäddade. Alternativen för storlek, färg och utdata gäller inte.", "read in the wrong units.": "läses in i fel enheter.", "Read Metadata from File": "Läs metadata från fil", + "Saving metadata to files": "Sparar metadata till filer", + "Reading metadata from files": "Läser metadata från filer", + "Save Metadata to Files": "Spara metadata till filer", + "Read Metadata from Files": "Läs metadata från filer", + "Save or Read Folder Metadata in the Background": "Spara eller läs mappens metadata i bakgrunden", "Read metadata updates from XMP sidecars": "Läs metadatauppdateringar från XMP-sidofiler", "Read mode": "Läsläge", "Read the SAM License": "Läs SAM-licensen", diff --git a/crates/ui-egui/locales/uk.json b/crates/ui-egui/locales/uk.json index ee694ed4fe0..d1cacc9f918 100644 --- a/crates/ui-egui/locales/uk.json +++ b/crates/ui-egui/locales/uk.json @@ -1214,6 +1214,11 @@ "Raw photos": "Фото RAW", "Raw photos as DNG, with the edits embedded. Size, color and output options don't apply.": "Фото RAW як DNG із вбудованими змінами. Параметри розміру, кольору й виведення не застосовуються.", "Read Metadata from File": "Прочитати метадані з файлу", + "Saving metadata to files": "Збереження метаданих до файлів", + "Reading metadata from files": "Читання метаданих із файлів", + "Save Metadata to Files": "Зберегти метадані до файлів", + "Read Metadata from Files": "Прочитати метадані з файлів", + "Save or Read Folder Metadata in the Background": "Зберегти або прочитати метадані теки у фоні", "Reading folder…": "Читання теки…", "Recently Added": "Нещодавно додані", "Recently Deleted": "Нещодавно видалені", diff --git a/crates/ui-egui/locales/vi.json b/crates/ui-egui/locales/vi.json index e4fb8feb81c..abbe5ad19ed 100644 --- a/crates/ui-egui/locales/vi.json +++ b/crates/ui-egui/locales/vi.json @@ -1409,6 +1409,11 @@ "Raw photos": "Ảnh RAW", "Raw photos as DNG, with the edits embedded. Size, color and output options don't apply.": "Ảnh raw dạng DNG, nhúng chỉnh sửa. Tùy chọn kích thước, màu và đầu ra không áp dụng.", "Read Metadata from File": "Đọc siêu dữ liệu từ tệp", + "Saving metadata to files": "Đang lưu siêu dữ liệu vào các tệp", + "Reading metadata from files": "Đang đọc siêu dữ liệu từ các tệp", + "Save Metadata to Files": "Lưu siêu dữ liệu vào các tệp", + "Read Metadata from Files": "Đọc siêu dữ liệu từ các tệp", + "Save or Read Folder Metadata in the Background": "Lưu hoặc đọc siêu dữ liệu của thư mục trong nền", "Read metadata updates from XMP sidecars": "Đọc cập nhật siêu dữ liệu từ sidecar XMP", "Read mode": "Chế độ đọc", "Read the SAM License": "Đọc giấy phép SAM", diff --git a/crates/ui-egui/locales/zh-hans.json b/crates/ui-egui/locales/zh-hans.json index 270af8a6251..9638caf53ba 100644 --- a/crates/ui-egui/locales/zh-hans.json +++ b/crates/ui-egui/locales/zh-hans.json @@ -1152,6 +1152,11 @@ "Raw photos": "RAW 照片", "Raw photos as DNG, with the edits embedded. Size, color and output options don't apply.": "将 RAW 照片导出为内嵌编辑设置的 DNG。大小、颜色和输出选项不适用。", "Read Metadata from File": "从文件读取元数据", + "Saving metadata to files": "正在将元数据保存到文件", + "Reading metadata from files": "正在从文件读取元数据", + "Save Metadata to Files": "将元数据保存到文件", + "Read Metadata from Files": "从文件读取元数据", + "Save or Read Folder Metadata in the Background": "在后台保存或读取文件夹的元数据", "Read mode": "阅读模式", "Reading": "正在读取", "Reading folder…": "正在读取文件夹…", diff --git a/crates/ui-egui/locales/zh-hant.json b/crates/ui-egui/locales/zh-hant.json index 0408e23ec87..2bbd8d332ea 100644 --- a/crates/ui-egui/locales/zh-hant.json +++ b/crates/ui-egui/locales/zh-hant.json @@ -1153,6 +1153,11 @@ "Raw photos": "RAW 照片", "Raw photos as DNG, with the edits embedded. Size, color and output options don't apply.": "將 RAW 照片轉為 DNG,並內嵌編輯設定。尺寸、色彩與輸出選項不適用。", "Read Metadata from File": "從檔案讀取中繼資料", + "Saving metadata to files": "正在將中繼資料儲存至檔案", + "Reading metadata from files": "正在從檔案讀取中繼資料", + "Save Metadata to Files": "將中繼資料儲存至檔案", + "Read Metadata from Files": "從檔案讀取中繼資料", + "Save or Read Folder Metadata in the Background": "在背景儲存或讀取資料夾的中繼資料", "Read mode": "閱讀模式", "Reading": "正在讀取", "Reading folder…": "正在讀取資料夾…", diff --git a/docs/background-tasks.md b/docs/background-tasks.md index 0c9281dfc22..5d79f580902 100644 --- a/docs/background-tasks.md +++ b/docs/background-tasks.md @@ -33,7 +33,7 @@ guard.detail(&file_name); dead job never leaves a stuck bar. A worker that only reports progress takes a `TaskHandle` (`guard.handle()`, `Clone + Send`). - **`kind`** is a stable camelCase id that agents filter by (`export`, `import`, `scan`, `sync`, `previews`, - `download`, `faces`, `cache`, `focus`…). **`label`** is a short English name in sentence case ("Building previews"). The stack shows it + `download`, `faces`, `cache`, `focus`, `saveMetadata`, `readMetadata`…). **`label`** is a short English name in sentence case ("Building previews"). The stack shows it translated, so add it to every catalog in `crates/ui-egui/locales/`. - **Progress:** `progress(done, total)`. A `total` of 0 means the amount of work isn't known yet, and the bar sweeps. `set_unit(Unit::Bytes)` makes the count read "12 of 340 MB"; `Unit::Percent` reads "40 %". The default `Unit::Count` @@ -56,6 +56,7 @@ guard.detail(&file_name); | Export, contact sheet | `crates/ui-egui/src/export_task.rs` | adopt the job's flag; update the row each frame | | Build Previews | `crates/engine/src/cmd/previews.rs` | move the guard into the worker thread | | Slideshow export | `crates/engine/src/cmd/slideshow.rs`, `crates/engine/src/slideshow_export.rs` | an engine command that owns its worker and row; progress from the worker through a `TaskHandle`; results read back by command | +| Folder metadata save / read | `crates/engine/src/cmd/folder_metadata.rs` | a job that needs the session, so a per-frame pump (`folder.metadataPump`) does a few photos at a time and the row's flag stops it | | Model downloads | `crates/engine/src/face_download.rs` | report progress through a `TaskHandle` in shared state | | Lightroom catalog import | `crates/ui-egui/src/lightroom_import.rs` | stop being cancellable for a phase that must finish | | Face scan, AI Denoise | `crates/engine/src/cmd/face_recognize.rs`, `crates/engine/src/denoise.rs` | a continuous job with no ✕, kept in session state | diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 90cfc248f60..0820b2959d6 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -1,6 +1,6 @@ # Lightroom parity checklist -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-25 · **Change:** minor (LR-BEHAV-TITLEBAR: a double-click follows the system setting, and a panel over the bar keeps the window still; KEYC-METADATA, LRC-LIB-KEYWORDS: ⌥0 / ⌥⇧0 go to the next / previous keyword set; LRC-DEV-HISTOGRAM-DRAG: the histogram's five tonal zones — hover for the value, drag to adjust the Basic control the press locked, double-click to reset; LR-VIEW-HISTOGRAM note updated; MENU-BAR: on macOS a menu item that yields its key to a focused text field or to shortcut recording really lets it go; LR-MERGE-HDR / LR-MERGE-PANO: Lanczos-3 warps; LR-IMP-LOCAL: browsing from the sidebar records the folder; LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict; LR-IMP-ADD-DIALOG: hierarchical import album destination reconciled with main, #2362; KEY-SLIDER-NUDGE: vertical wheel nudges need a click or drag in the row; leaving it disarms them; LR-EDIT-OPTICS-PROFILE: Fujifilm nine-knot lens tables read at the plain radius; LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict; LRC-LIB-LIBFOLDERS, LR-BEHAV-BG-TASKS: Synchronize Folder's scan shows its folder listing and stops it on ✕; LRC-LIB-LIBFOLDERS: Synchronize Folder says a folder is up to date; LR-LIB-STACK: filmstrip stack badge click; LRC-LIB-REFVIEW / CATALOG-SWITCH: Escape preserves edits; catalog-local pins; deleted and malformed references refused; LRC-LIB-COMPARE: the Info panel labels the active photo while culling, #2398; KEYC-RATING: `\` shows / hides the Filter Bar in the grids; LR-VIEW-PHOTOGRID: the grid reads only the photos an import batch or an edit touched, not the whole list; earlier: LRC-PRINT-PAGE: Print Page Options; LR-META-XMP: fewer false unimported-XMP warnings; KEYC-METADATA: ⌘K / Ctrl+K Add Keywords; LRC-DEV-HISTOGRAM-DRAG: the histogram's five tonal zones — hover for the value, drag to adjust the Basic control the press locked, double-click to reset; LR-VIEW-HISTOGRAM note updated; MENU-BAR: on macOS a menu item that yields its key to a focused text field or to shortcut recording really lets it go; LR-MERGE-HDR / LR-MERGE-PANO: Lanczos-3 warps; LR-IMP-LOCAL: browsing from the sidebar records the folder; LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict; LR-IMP-ADD-DIALOG: hierarchical import album destination reconciled with main, #2362; KEY-SLIDER-NUDGE: vertical wheel nudges need a click or drag in the row; leaving it disarms them; LR-EDIT-OPTICS-PROFILE: Fujifilm nine-knot lens tables read at the plain radius; LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict; LRC-LIB-LIBFOLDERS, LR-BEHAV-BG-TASKS: Synchronize Folder's scan shows its folder listing and stops it on ✕; LRC-LIB-LIBFOLDERS: Synchronize Folder says a folder is up to date; LR-LIB-STACK: filmstrip stack badge click; LRC-LIB-REFVIEW / CATALOG-SWITCH: Escape preserves edits; catalog-local pins; deleted and malformed references refused; LRC-LIB-COMPARE: the Info panel labels the active photo while culling, #2398; KEYC-RATING: `\` shows / hides the Filter Bar in the grids; LR-VIEW-PHOTOGRID: the grid reads only the photos an import batch or an edit touched, not the whole list; earlier: LRC-PRINT-PAGE: Print Page Options; LR-META-XMP: fewer false unimported-XMP warnings) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-25 · **Change:** minor (LR-META-XMP: `folder.saveMetadata` and `folder.readMetadata` save or read the sidecars of every library photo of a folder and the folders inside it, with an activity row, run in the background by `folder.metadataPump` or in one call (engine only; the Folders menu items come later); LR-BEHAV-TITLEBAR: a double-click follows the system setting, and a panel over the bar keeps the window still; KEYC-METADATA, LRC-LIB-KEYWORDS: ⌥0 / ⌥⇧0 go to the next / previous keyword set; LRC-DEV-HISTOGRAM-DRAG: the histogram's five tonal zones — hover for the value, drag to adjust the Basic control the press locked, double-click to reset; LR-VIEW-HISTOGRAM note updated; MENU-BAR: on macOS a menu item that yields its key to a focused text field or to shortcut recording really lets it go; LR-MERGE-HDR / LR-MERGE-PANO: Lanczos-3 warps; LR-IMP-LOCAL: browsing from the sidebar records the folder; LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict; LR-IMP-ADD-DIALOG: hierarchical import album destination reconciled with main, #2362; KEY-SLIDER-NUDGE: vertical wheel nudges need a click or drag in the row; leaving it disarms them; LR-EDIT-OPTICS-PROFILE: Fujifilm nine-knot lens tables read at the plain radius; LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict; LRC-LIB-LIBFOLDERS, LR-BEHAV-BG-TASKS: Synchronize Folder's scan shows its folder listing and stops it on ✕; LRC-LIB-LIBFOLDERS: Synchronize Folder says a folder is up to date; LR-LIB-STACK: filmstrip stack badge click; LRC-LIB-REFVIEW / CATALOG-SWITCH: Escape preserves edits; catalog-local pins; deleted and malformed references refused; LRC-LIB-COMPARE: the Info panel labels the active photo while culling, #2398; KEYC-RATING: `\` shows / hides the Filter Bar in the grids; LR-VIEW-PHOTOGRID: the grid reads only the photos an import batch or an edit touched, not the whole list; earlier: LRC-PRINT-PAGE: Print Page Options; LR-META-XMP: fewer false unimported-XMP warnings; KEYC-METADATA: ⌘K / Ctrl+K Add Keywords; LRC-DEV-HISTOGRAM-DRAG: the histogram's five tonal zones — hover for the value, drag to adjust the Basic control the press locked, double-click to reset; LR-VIEW-HISTOGRAM note updated; MENU-BAR: on macOS a menu item that yields its key to a focused text field or to shortcut recording really lets it go; LR-MERGE-HDR / LR-MERGE-PANO: Lanczos-3 warps; LR-IMP-LOCAL: browsing from the sidebar records the folder; LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict; LR-IMP-ADD-DIALOG: hierarchical import album destination reconciled with main, #2362; KEY-SLIDER-NUDGE: vertical wheel nudges need a click or drag in the row; leaving it disarms them; LR-EDIT-OPTICS-PROFILE: Fujifilm nine-knot lens tables read at the plain radius; LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict; LRC-LIB-LIBFOLDERS, LR-BEHAV-BG-TASKS: Synchronize Folder's scan shows its folder listing and stops it on ✕; LRC-LIB-LIBFOLDERS: Synchronize Folder says a folder is up to date; LR-LIB-STACK: filmstrip stack badge click; LRC-LIB-REFVIEW / CATALOG-SWITCH: Escape preserves edits; catalog-local pins; deleted and malformed references refused; LRC-LIB-COMPARE: the Info panel labels the active photo while culling, #2398; KEYC-RATING: `\` shows / hides the Filter Bar in the grids; LR-VIEW-PHOTOGRID: the grid reads only the photos an import batch or an edit touched, not the whole list; earlier: LRC-PRINT-PAGE: Print Page Options; LR-META-XMP: fewer false unimported-XMP warnings) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6 The measured, row-by-row checklist: one row per Lightroom feature, menu item and shortcut, what we have and what is missing. It answers *does the feature exist?* (feature breadth). Whether it is good @@ -168,7 +168,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-META-COPYRIGHT-DEFAULT | Default copyright on import | P1 | ✅ | `cmd:library.preferences` (`import.copyright`, `import.creator`), `crates/ui-egui/src/dialogs/settings.rs` | Settings → Import → Metadata; fills only photos without their own | | LR-META-LOCATION | Location editing | P2 | 🟡 | `cmd:photo.setMeta` (`location`, `city`, `state`, `country`, `gps`), `cmd:metadata.reverseGeocode` | place fields and GPS (decimal or degrees / minutes / seconds) edited in Info, read/written as IPTC Core / Photoshop / EXIF XMP; Show on Map opens OpenStreetMap; Fill Location fills empty City / State / Country from GPS offline (GeoNames, downloaded on request: `cmd:metadata.downloadPlaceNames`); no embedded map | | LR-META-COPYPASTE | Copy / paste metadata | P2 | ✅ | `cmd:photo.copyMetadata`, `cmd:photo.pasteMetadata` | title, caption, alt text, extended description, copyright (notice, status, usage terms, info URL), creator, place fields, keywords; `fields` picks a subset | -| LR-META-XMP | XMP read/write | P0 | ✅ | `cmd:photo.saveMetadataToFile`, `cmd:photo.readMetadataFromFile`, `cmd:library.xmpPreferences`, `crates/engine/src/sidecar.rs`, `docs/xmp-interop.md` | manual rereading also reads sidecar-free JPEG embedded XMP (first complete standard APP1 before SOS/EOI, within 16 MiB of headers and 4096 marker/fill steps; no extended assembly or between-scan packets, not strict whole-JPEG validation; reader cases in `crates/engine/src/sidecar.rs`); a discovered unreadable sidecar fails without embedded fallback; procedural refresh/undo, non-UTF-8 sidecar and two explicit malformed fixtures in `crates/engine/src/tests/xmp.rs` (file-write checks use auto-write off); sidecar wins for metadata; a sidecar capture time (`exif:DateTimeOriginal` / `photoshop:DateCreated` / `xmp:CreateDate`) fills in only when the file has none; saving merges into an existing sidecar (`crates/meta/src/xmp_merge.rs`): another app's `crs:`, `xmpMM:History` and unknown namespaces are kept byte for byte (ownership follows namespace URI: foreign namespaces using `lc:` or `xmp:` cannot supply native settings or ratings and survive saving), an unreadable sidecar is backed up first; with stem naming, files sharing a stem (raw + JPEG) get separate sidecars (`.xmp` for all but the raw; an import ranks the files it is adding the same way, so a TIFF or JPEG arriving beside its raw reads its own `.xmp` and never the raw's `IMG_0001.xmp`, issue #1905); a `crs:` custom white balance on a relative-WB raw is shifted from `crs:AsShotTemperature` rather than read as Kelvin, or kept As Shot and reported when the packet has no as-shot white (issue #510); heal and clone spots (`crs:RetouchAreas`, legacy `crs:RetouchInfo`) are read into our spots (`crates/engine/src/crs_masks.rs`, see `docs/xmp-interop.md` → Spot removal); radial masks (`Mask/CircularGradient`) keep Lightroom's inside / outside: `crs:Flipped="true"` is the effect-inside flag of current masks and of the legacy Radial Filter, `crs:MaskInverted` the inversion, checked against Lightroom Classic's renders (issue #1815); Read Metadata from File never writes the sidecar back, even with auto-write on, so another app's later `crs:` edits are still read (issue #934); settings Lightroom writes only for itself (`CompatibleVersion`, the profile digests, the lens profile's name / file / setup, `CropConstrainToUnitSquare`, the lens profile's strength at 100 %) are not reported as unimported (`crates/engine/src/crs.rs`) | +| LR-META-XMP | XMP read/write | P0 | ✅ | `cmd:photo.saveMetadataToFile`, `cmd:photo.readMetadataFromFile`, `cmd:library.xmpPreferences`, `crates/engine/src/sidecar.rs`, `docs/xmp-interop.md` | manual rereading also reads sidecar-free JPEG embedded XMP (first complete standard APP1 before SOS/EOI, within 16 MiB of headers and 4096 marker/fill steps; no extended assembly or between-scan packets, not strict whole-JPEG validation; reader cases in `crates/engine/src/sidecar.rs`); a discovered unreadable sidecar fails without embedded fallback; procedural refresh/undo, non-UTF-8 sidecar and two explicit malformed fixtures in `crates/engine/src/tests/xmp.rs` (file-write checks use auto-write off); sidecar wins for metadata; a sidecar capture time (`exif:DateTimeOriginal` / `photoshop:DateCreated` / `xmp:CreateDate`) fills in only when the file has none; saving merges into an existing sidecar (`crates/meta/src/xmp_merge.rs`): another app's `crs:`, `xmpMM:History` and unknown namespaces are kept byte for byte (ownership follows namespace URI: foreign namespaces using `lc:` or `xmp:` cannot supply native settings or ratings and survive saving), an unreadable sidecar is backed up first; with stem naming, files sharing a stem (raw + JPEG) get separate sidecars (`.xmp` for all but the raw; an import ranks the files it is adding the same way, so a TIFF or JPEG arriving beside its raw reads its own `.xmp` and never the raw's `IMG_0001.xmp`, issue #1905); a `crs:` custom white balance on a relative-WB raw is shifted from `crs:AsShotTemperature` rather than read as Kelvin, or kept As Shot and reported when the packet has no as-shot white (issue #510); heal and clone spots (`crs:RetouchAreas`, legacy `crs:RetouchInfo`) are read into our spots (`crates/engine/src/crs_masks.rs`, see `docs/xmp-interop.md` → Spot removal); radial masks (`Mask/CircularGradient`) keep Lightroom's inside / outside: `crs:Flipped="true"` is the effect-inside flag of current masks and of the legacy Radial Filter, `crs:MaskInverted` the inversion, checked against Lightroom Classic's renders (issue #1815); Read Metadata from File never writes the sidecar back, even with auto-write on, so another app's later `crs:` edits are still read (issue #934); `cmd:folder.saveMetadata` and `cmd:folder.readMetadata` do the same for every library photo imported from a folder and the folders inside it (not Local-only browse records, Recently Deleted or virtual copies): one activity row (`saveMetadata` / `readMetadata`), in one call or with `background: true` paced by `cmd:folder.metadataPump` so the row's ✕ stops it between photos, a photo whose file fails goes to `failed` and the rest go on, a stopped save keeps the sidecars written so far and a stopped read commits what it read as one undo step (`crates/engine/src/cmd/folder_metadata.rs`, tests in `crates/engine/src/tests/folder_metadata.rs`); settings Lightroom writes only for itself (`CompatibleVersion`, the profile digests, the lens profile's name / file / setup, `CropConstrainToUnitSquare`, the lens profile's strength at 100 %) are not reported as unimported (`crates/engine/src/crs.rs`) | | LR-META-EXIF-FULL | Full EXIF/IPTC [Classic] | P1 | ✅ | `cmd:photo.allMetadata`, `cmd:dialog.allMetadata`, `crates/meta/src/tags.rs`, `crates/meta/src/exif.rs`, `crates/meta/src/iptc.rs` | `photo.allMetadata` reuses loaded original bytes for embedded XMP and keeps sidecar precedence (`crates/engine/src/tests/xmp.rs`); read and written on export; Info ▸ All Metadata…: every TIFF / EXIF / GPS / interop tag (named, common values spelled out) and the XMP fields, searchable; PSD/PSB EXIF resource 1058 and XMP resource 1060 feed the same metadata rows and preserve sidecar precedence; metadata presets | ## F. Edit panel — global adjustments (EDIT) @@ -959,3 +959,4 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove | 2026-10-23 | patch | LR-BEHAV-ACCESS: the name field of New Album, New Smart Album, Rename and the other one-field dialogs takes the keyboard focus once when the dialog opens instead of every frame, so Tab and Shift+Tab reach the check box, Cancel and OK; status unchanged (🟡) | | 2026-10-22 | minor | LR-CROP-AUTO: Auto straighten turns by at most 10° and only on at least 3 agreeing lines, and says when it finds nothing to level by; measured on 68 photos straightened by hand and 300 left as shot, unwanted turns of more than 1° fell from 79 to 19 of the 300. Downgraded ✅ → 🟡: it still leaves most tilted photos alone | | 2026-10-23 | patch | LRC-LIB-FILTERBAR: showing an album (`library.source`) while the filter holds an album drops the filter's album, as showing a library folder already dropped its folder filter; before, the old album stayed in the filter unseen (the filter bar has no album chip) and narrowed the next source such as All Photos; the row's note says so; status unchanged (✅) | +| 2026-10-25 | minor | LR-META-XMP: `folder.saveMetadata` and `folder.readMetadata` save or read the XMP sidecars of every library photo of a folder and the folders inside it, with a row in the activity stack that a background run lets stop; engine only, the Folders and Local folder menu items follow; status unchanged (✅) | diff --git a/docs/whats-new.md b/docs/whats-new.md index c6c25920034..6d452d3f4f0 100644 --- a/docs/whats-new.md +++ b/docs/whats-new.md @@ -1,5 +1,15 @@ # What's new in LightCraft +## 2026-10-25 + +### Save or read the metadata of a whole folder from a script +- `folder.saveMetadata {path}` and `folder.readMetadata {path}` (CLI and MCP) do what Save Metadata to File and Read + Metadata from File do for the selection, for every library photo imported from a folder and the folders inside it. + Each run shows a row in the activity stack. With `background: true` the work only advances while the caller runs + `folder.metadataPump` again and again (the app doesn't yet), and then the row's ✕ stops it between photos: a stopped + save keeps the sidecars it wrote, a stopped read commits what it read as one undo step. A photo whose file can't be + written or read is listed in `failed` and the rest go on. The Folders menu items that use them come later. + ## 2026-10-24 ### Relative-date filters and smart albums follow the clock diff --git a/docs/xmp-interop.md b/docs/xmp-interop.md index 0f455118249..c9dc7f03d45 100644 --- a/docs/xmp-interop.md +++ b/docs/xmp-interop.md @@ -9,8 +9,8 @@ other tools), and let LightCraft pick up edits made elsewhere. | | | |---|---| | Name | `.xmp` by default (`IMG_0001.CR3` → `IMG_0001.xmp`); `.xmp` (`IMG_0001.CR3.xmp`) with `naming: "full"`. Reading accepts either (preferred first) and `.XMP`. With stem naming, files sharing a stem don't share a sidecar: see *Shared names* below. | -| Write | `photo.saveMetadataToFile {ids?}` (Photo ▸ Save Metadata to File, ⌘S), or automatically after every change with `library.xmpPreferences {autoWrite: true}` (File ▸ Automatically Write Changes into XMP). Slider drags are written once, when the drag ends; undo/redo rewrite the sidecar. An existing sidecar is **merged into, never replaced** (see *Saving into an existing sidecar*). Written atomically (temp file, fsync, rename). The result lists `written`, `merged` and `backups`. | -| Read | On import (`library.import`, the report counts `sidecars`), and `photo.readMetadataFromFile {ids?}` (one undo step). Manual rereading uses embedded XMP in raw/DNG and JPEG files when no sidecar exists. A discovered sidecar that cannot be read or parsed is reported in `failed`, without applying embedded values. `photo.readMetadataFromFile` never writes the sidecar, even with auto-write on: writing back what it has just read would add `lc:settings`, which later reads prefer over another app's `crs:` edits (issue #934). A file arriving in an import is ranked as if it were catalogued already: it reads its own `.xmp` when another file of its stem (a raw first) owns the shared stem sidecar (issue #1905). | +| Write | `photo.saveMetadataToFile {ids?}` (Photo ▸ Save Metadata to File, ⌘S), or automatically after every change with `library.xmpPreferences {autoWrite: true}` (File ▸ Automatically Write Changes into XMP). Slider drags are written once, when the drag ends; undo/redo rewrite the sidecar. An existing sidecar is **merged into, never replaced** (see *Saving into an existing sidecar*). Written atomically (temp file, fsync, rename). The result lists `written`, `merged` and `backups`. `folder.saveMetadata {path, background?}` does the same for every library photo imported from a folder and the folders inside it (not Local-only browse records, Recently Deleted or virtual copies), with a row in the activity stack; a photo whose file can't be written lands in `failed` and the rest go on. Plain, it does every photo before it returns; with `background: true` it only plans the work and `folder.metadataPump` (a frontend calls it every frame) does it a few milliseconds at a time, so the row shows its count and its ✕ stops it between photos (the sidecars already written stay, `cancelled: true`). | +| Read | On import (`library.import`, the report counts `sidecars`), and `photo.readMetadataFromFile {ids?}` (one undo step). Manual rereading uses embedded XMP in raw/DNG and JPEG files when no sidecar exists. A discovered sidecar that cannot be read or parsed is reported in `failed`, without applying embedded values. `photo.readMetadataFromFile` never writes the sidecar, even with auto-write on: writing back what it has just read would add `lc:settings`, which later reads prefer over another app's `crs:` edits (issue #934). `folder.readMetadata {path, background?}` reads every library photo of a folder and the folders inside it the same way (one undo step, never writes the sidecars; a photo without a readable sidecar, or edited while a background read waited, is in `failed` while the rest are read; stopped, it commits what it had read). A file arriving in an import is ranked as if it were catalogued already: it reads its own `.xmp` when another file of its stem (a raw first) owns the shared stem sidecar (issue #1905). | | Preferences | `library.xmpPreferences {autoWrite?, naming?: stem\|full}`, stored in the library's `prefs.json`. | What we write (standard namespaces, so other tools can read the metadata):