Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

LR-VIEW-PHOTOGRID: a batch that cannot be rolled back whole makes a revision

Nathaniel Ledfordbd485adc8976
diff --git a/crates/catalog/src/lib.rs b/crates/catalog/src/lib.rs
index 59e9b0f52..99808f2ba 100644
--- a/crates/catalog/src/lib.rs
+++ b/crates/catalog/src/lib.rs
@@ -627,10 +627,13 @@ impl Catalog {
Err(e) => {
let made = self.revision.saturating_add(1);
if self.changes.torn {
- // (a batch the rollback of which failed changed something and says not what: anything may
- // have changed, as after an op of a wider reach)
+ // (a batch the rollback of which failed changed something and says not what: it makes a
+ // revision, so what is kept for the one before is dropped, and anything may have changed, as
+ // after an op of a wider reach)
self.changes.torn = false;
self.changes.broad = made;
+ self.revision = made;
+ self.changes.seen = made;
} else {
// (everything the failed op, or the rollback of a batch, noted was made for the revision it
// would have made: nothing earlier has that one. A note the cap already dropped stays
diff --git a/crates/catalog/src/tests.rs b/crates/catalog/src/tests.rs
index f76d57bbc..579175086 100644
--- a/crates/catalog/src/tests.rs
+++ b/crates/catalog/src/tests.rs
@@ -1041,7 +1041,8 @@ fn a_batch_that_cannot_be_rolled_back_whole_makes_earlier_changes_unknown() {
let failing =
Op::Batch { ops: vec![Op::RemovePhoto { id: ids[0] }, Op::RemoveStack { id: stack }, Op::SetRating { id: PhotoId(9_999), rating: 1 }] };
assert!(c.apply(failing).is_err());
- assert_eq!(c.revision, start);
+ assert_eq!(c.revision, start + 1, "the catalog changed, so what is kept for the revision before is out of date");
assert!(c.photo(ids[0]).is_some() && c.stack(stack).is_none(), "the rollback went only part of the way");
assert_eq!(c.touched_since(start), None, "so nothing is said of what changed");
+ assert_eq!(c.touched_since(c.revision), Some(vec![]), "from after it, it is known again");
}