From c6acf9e642b35442f9c39dd3d3ffc0ade815ce7a Mon Sep 17 00:00:00 2001 From: Nathaniel Ledford Date: Sat, 24 Oct 2026 00:03:28 -0400 Subject: [PATCH] LR-VIEW-PHOTOGRID: say in the docs that a failed rollback advances the revision The revision field and Catalog::apply said an error changes nothing and that the revision counts applied ops; a batch whose rollback fails changes the catalog and advances it. --- crates/catalog/src/lib.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/catalog/src/lib.rs b/crates/catalog/src/lib.rs index 99808f2ba..ea75119e4 100644 --- a/crates/catalog/src/lib.rs +++ b/crates/catalog/src/lib.rs @@ -284,7 +284,8 @@ pub struct Catalog { /// What the library keeps about its folders (folder identity → record), see [`folders`]. #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] folder_records: BTreeMap, - /// Increments on every applied op. + /// Increments on every applied op, and when a batch fails and its rollback cannot undo it whole (the catalog + /// changed, so what is keyed by the revision is out of date). #[serde(skip)] pub revision: u64, /// Which photos the latest ops touched ([`Catalog::touched_since`]). @@ -612,9 +613,9 @@ impl Catalog { self.albums.get_mut(&id).ok_or(CatalogError::NoAlbum(id)) } - /// Apply an op; returns its inverse. On error nothing changes, and nothing is remembered of the op in what the - /// latest ops touched; only a batch that could not be rolled back whole is remembered as "anything may have - /// changed". + /// Apply an op; returns its inverse. On error the catalog is as it was, the revision included, and nothing is + /// remembered of the op in what the latest ops touched. The one exception is a batch whose rollback fails: the + /// catalog did change, so the revision advances and anything may be taken to have changed. pub fn apply(&mut self, op: Op) -> Result { if self.changes.seen != self.revision { // the revision was set from outside: what is remembered is of another past